private void RotationBaseOnCameraOrientaion(PlayerController playerController) { float h = playerController.Movement.Horizontal; float v = playerController.Movement.Vertical; Vector3 targetDirection = cameraTransform.forward * v + cameraTransform.right * h; targetDirection.Normalize(); targetDirection.y = 0; if (targetDirection == Vector3.zero) { targetDirection = playerController.transform.forward; } //QuickTurnLeft if (Vector3.Angle(playerController.TargetDirection, targetDirection) > 179f) { playerController.TargetDirection = targetDirection; playerController.Animator.CrossFade(AnimatorHashes.QuickTurnLeftState, 0.2f); playerController.TransitionState(RotateBack); return; } playerController.TargetDirection = targetDirection; Quaternion tragetRotation = Quaternion.LookRotation(targetDirection); playerController.transform.rotation = Quaternion.Slerp(playerController.transform.rotation, tragetRotation, playerController.DeltaTime * playerController.Movement.MoveAmount * RotateSpeed); }
public override void OnUpdate(PlayerController playerController) { curWaitTime += playerController.DeltaTime; if (curWaitTime >= WaitTime) { WaitTime = 0; curWaitTime = 0; playerController.TransitionState(TargetState); } }
public override void OnUpdate(PlayerController playerController) { if (playerController.Movement.MoveAmount < 0.01f) { playerController.TransitionState(IdleState, false); return; } RotationBaseOnCameraOrientaion(playerController); Movement(playerController); }
public override void OnUpdate(PlayerController playerController) { t += playerController.DeltaTime * turnSpeed; Quaternion tragetRotation = Quaternion.LookRotation(playerController.TargetDirection); playerController.transform.rotation = Quaternion.Lerp(lastRotation, tragetRotation, t); if (t >= 1f) { t = 0; playerController.TransitionState(LocomotionState); return; } }
public override void OnUpdate(PlayerController playerController) { if (playerController.Movement.MoveAmount > 0.001f) { playerController.TransitionState(LocomotionState); return; } if (playerController.IsJump) { playerController.IsJump = false; playerController.Animator.CrossFade(AnimatorHashes.JumpIdleState, 0.2f); playerController.EntWaitState(jumpWaitTime, this); return; } }