예제 #1
0
        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);
        }
예제 #2
0
 public override void OnUpdate(PlayerController playerController)
 {
     curWaitTime += playerController.DeltaTime;
     if (curWaitTime >= WaitTime)
     {
         WaitTime    = 0;
         curWaitTime = 0;
         playerController.TransitionState(TargetState);
     }
 }
예제 #3
0
        public override void OnUpdate(PlayerController playerController)
        {
            if (playerController.Movement.MoveAmount < 0.01f)
            {
                playerController.TransitionState(IdleState, false);
                return;
            }

            RotationBaseOnCameraOrientaion(playerController);

            Movement(playerController);
        }
예제 #4
0
파일: RotateBack.cs 프로젝트: cofdream/Null
        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;
            }
        }
예제 #5
0
파일: IdleState.cs 프로젝트: cofdream/Null
        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;
            }
        }