Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- verticalVel -= 0;
- } else {
- verticalVel -= 2;
- }
- moveVector = new Vector3 (0, verticalVel, 0);
- controller.Move (moveVector);
- //
- }
- void PlayerMoveAndRotation() {
- InputX = Input.GetAxis ("Horizontal");
- InputZ = Input.GetAxis ("Vertical");
- var camera = Camera.main;
- var forward = cam.transform.forward;
- var right = cam.transform.right;
- forward.y = 0f;
- right.y = 0f;
- forward.Normalize ();
- right.Normalize ();
- desiredMoveDirection = forward * InputZ + right * InputX;
- if (blockRotationPlayer == false) {
- transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation (desiredMoveDirection), desiredRotationSpeed);
- }
- }
- void InputMagnitude() {
- //Calculate Input Vectors
- InputX = Input.GetAxis ("Horizontal");
- InputZ = Input.GetAxis ("Vertical");
- anim.SetFloat ("InputZ", InputZ, 0.0f, Time.deltaTime * 2f);
- anim.SetFloat ("InputX", InputX, 0.0f, Time.deltaTime * 2f);
- //Calculate the Input Magnitude
- Speed = new Vector2(InputX, InputZ).sqrMagnitude;
- //Physically move player
- if (Speed > allowPlayerRotation) {
- anim.SetFloat ("InputMagnitude", Speed, 0.0f, Time.deltaTime);
- PlayerMoveAndRotation ();
- } else if (Speed < allowPlayerRotation) {
- anim.SetFloat ("InputMagnitude", Speed, 0.0f, Time.deltaTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement