private void PrivModifiedMove(Vector3 direction, ObjectInteractionController oicCaller, Collider other) { SplinePlayerCharacterController otherPcc = other.transform.GetComponent <SplinePlayerCharacterController>(); float dotMagnitude = Vector3.Dot(plantSpline.transform.TransformVector(plantSpline.GetDirection(plantProgress).normalized), direction); if (!otherPcc.currPlayerStatus[PlayerCharacterController.StatusListElement.ROOTED]) { if (Math.Abs(dotMagnitude) > 0.05f) { // Lerp-Rotate the rigidbody toward the direction //Debug.Log(Time.timeSinceLevelLoad+" - SplineDir " + plantSpline.GetDirection(plantProgress).normalized // +"playerDir"+ direction); //plantProgress = plantSpline.GetLengthAtDistFromParametric(Math.Sign(dotMagnitude) * otherPcc.charSpeed * Time.deltaTime, plantProgress); //Vector3 newPosition = plantSpline.GetPoint(plantProgress); //Quaternion targetRotation = Quaternion.LookRotation(Math.Sign(dotMagnitude) * plantSpline.GetDirection(plantProgress).normalized, Vector3.up); //Quaternion newRotation = Quaternion.Lerp(otherPcc.pcc_rigidbody.rotation, targetRotation, otherPcc.turnSmooth); //transform.SetPositionAndRotation(newPosition, newRotation); //otherPcc.pcc_animator.SetFloat("Speed", 4.5f, otherPcc.speedDamptime, Time.deltaTime); plantProgress = plantSpline.GetLengthAtDistFromParametric(Math.Sign(dotMagnitude) * otherPcc.charSpeed * Time.deltaTime, plantProgress); Vector3 newPosition = plantSpline.GetPoint(plantProgress); Quaternion targetRotation = Quaternion.LookRotation(Math.Sign(dotMagnitude) * plantSpline.transform.TransformVector(plantSpline.GetDirection(plantProgress).normalized), Vector3.up); Quaternion newRotation = Quaternion.Lerp(otherPcc.pcc_rigidbody.rotation, targetRotation, otherPcc.turnSmooth); otherPcc.transform.SetPositionAndRotation(newPosition, newRotation); transform.position = otherPcc.transform.position + (this.transform.position - hidePosition.position); //otherPcc.pcc_animator.SetFloat("Speed", 5.7f, otherPcc.speedDamptime, Time.deltaTime); otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.HIDDEN, false); } else { otherPcc.pcc_animator.SetFloat("Speed", 0f, otherPcc.speedDamptime, Time.deltaTime); } } else { if (Math.Abs(dotMagnitude) > 0.05f) { otherPcc.transform.rotation = Quaternion.LookRotation(Math.Sign(dotMagnitude) * plantSpline.GetDirection(plantProgress).normalized, Vector3.up); otherPcc.pcc_animator.SetFloat("Speed", 0f, otherPcc.speedDamptime, Time.deltaTime); } } }
private IEnumerator MoveInVentialtion() { float splineSize = VentiSpline.GetLength(1.0f); while (currProgress < 1.0f) { //currProgress += Time.deltaTime / duration; currProgress = VentiSpline.GetLengthAtDistFromParametric(splineSize * Time.deltaTime / duration, currProgress); if (currProgress > 1.0f) { currProgress = 1.0f; } pcc.transform.SetPositionAndRotation( VentiSpline.GetPoint(currProgress), Quaternion.Euler(VentiSpline.GetDirection(currProgress))); yield return(null); } // CallBack EndMoveInVentilation(); }
public override void Interaction(ObjectInteractionController oicCaller, Collider other) { if (other.tag == Tags.player) { SplinePlayerCharacterController otherPcc = other.transform.GetComponent <SplinePlayerCharacterController>(); bool isHidden = otherPcc.currPlayerStatus[PlayerCharacterController.StatusListElement.HIDDEN]; if (!isHidden) { otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.BEHINDPOT, true); otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.HIDDEN, true); deskProgress = deskSpline.GetNearestProgressOnSpline(otherPcc.transform.position); //otherPcc.transform.SetPositionAndRotation(deskSpline.GetNearestPointOnSpline(otherPcc.transform.position), // Quaternion.Euler(deskSpline.transform.TransformVector(deskSpline.GetDirection(deskProgress).normalized))); SoundManager.GetAudio(audioTPID).Play(); GameObject.Instantiate(Resources.Load("Prefabs/TPCloud"), pcc.transform.position, pcc.transform.rotation); float dotMagnitude = Vector3.Dot(otherPcc.transform.forward, Camera.main.transform.right); //Debug.Log("dotMagnitude:" + dotMagnitude); otherPcc.transform.SetPositionAndRotation(deskSpline.GetNearestPointOnSpline(otherPcc.transform.position), Quaternion.LookRotation(dotMagnitude * deskSpline.transform.TransformVector(deskSpline.GetDirection(deskProgress).normalized), Vector3.up)); } else { otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.HIDDEN, false); otherPcc.ChangeStatus(PlayerCharacterController.StatusListElement.BEHINDPOT, false); otherPcc.progress = otherPcc.lSpline.GetNearestProgressOnSpline(otherPcc.transform.position); SoundManager.GetAudio(audioTPID).Play(); GameObject.Instantiate(Resources.Load("Prefabs/TPCloud"), pcc.transform.position, pcc.transform.rotation); otherPcc.Move(otherPcc.transform.forward); } } }
//public Vector3 TESTSplinePosition; public override void ImplementedMove(Vector3 direction) { if (lSpline != null) { float dotMagnitude = Vector3.Dot(lSpline.GetDirection(progress).normalized, direction); if (!currPlayerStatus[StatusListElement.ROOTED]) { if (Math.Abs(dotMagnitude) > 0.05f) { // Lerp-Rotate the rigidbody toward the direction //Math.Sign(dotMagnitude) * charSpeed * Time.deltaTime progress = lSpline.GetLengthAtDistFromParametric(Math.Sign(dotMagnitude) * charSpeed * Time.deltaTime, progress); Vector3 newPosition = lSpline.GetPoint(progress); Quaternion targetRotation = Quaternion.LookRotation(Math.Sign(dotMagnitude) * lSpline.GetDirection(progress).normalized, Vector3.up); Quaternion newRotation = Quaternion.Lerp(pcc_rigidbody.rotation, targetRotation, turnSmooth); transform.SetPositionAndRotation(newPosition, newRotation); pcc_animator.SetFloat("Speed", 4.5f, speedDamptime, Time.deltaTime); } else { pcc_animator.SetFloat("Speed", 0f, speedDamptime, Time.deltaTime); } } else { if (Math.Abs(dotMagnitude) > 0.05f) { transform.rotation = Quaternion.LookRotation(Math.Sign(dotMagnitude) * lSpline.GetDirection(progress).normalized, Vector3.up); } pcc_animator.SetFloat("Speed", 0f, speedDamptime, Time.deltaTime); } } }