private void PrivModifiedMove(Vector3 direction, ObjectInteractionController oicCaller, Collider other) { SplinePlayerCharacterController otherPcc = other.transform.GetComponent <SplinePlayerCharacterController>(); float dotMagnitude = Vector3.Dot(deskSpline.transform.TransformVector(deskSpline.GetDirection(deskProgress).normalized), direction); if (!otherPcc.currPlayerStatus[PlayerCharacterController.StatusListElement.ROOTED]) { if (Math.Abs(dotMagnitude) > 0.05f) { deskProgress = deskSpline.GetLengthAtDistFromParametric(Math.Sign(dotMagnitude) * otherPcc.charSpeed * Time.deltaTime, deskProgress); Vector3 newPosition = deskSpline.GetPoint(deskProgress); Quaternion targetRotation = Quaternion.LookRotation(Math.Sign(dotMagnitude) * deskSpline.transform.TransformVector(deskSpline.GetDirection(deskProgress).normalized), Vector3.up); Quaternion newRotation = Quaternion.Lerp(otherPcc.pcc_rigidbody.rotation, targetRotation, otherPcc.turnSmooth); otherPcc.transform.SetPositionAndRotation(newPosition, newRotation); otherPcc.pcc_animator.SetFloat("Speed", 5.7f, otherPcc.speedDamptime, Time.deltaTime); } 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) * deskSpline.GetDirection(deskProgress).normalized, Vector3.up); otherPcc.pcc_animator.SetFloat("Speed", 0f, otherPcc.speedDamptime, Time.deltaTime); } } }
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 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); } } }