Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. verticalVel -= 0;
  2. } else {
  3. verticalVel -= 2;
  4. }
  5. moveVector = new Vector3 (0, verticalVel, 0);
  6. controller.Move (moveVector);
  7. //
  8. }
  9.  
  10. void PlayerMoveAndRotation() {
  11. InputX = Input.GetAxis ("Horizontal");
  12. InputZ = Input.GetAxis ("Vertical");
  13.  
  14. var camera = Camera.main;
  15. var forward = cam.transform.forward;
  16. var right = cam.transform.right;
  17.  
  18. forward.y = 0f;
  19. right.y = 0f;
  20.  
  21. forward.Normalize ();
  22. right.Normalize ();
  23.  
  24. desiredMoveDirection = forward * InputZ + right * InputX;
  25.  
  26. if (blockRotationPlayer == false) {
  27. transform.rotation = Quaternion.Slerp (transform.rotation, Quaternion.LookRotation (desiredMoveDirection), desiredRotationSpeed);
  28. }
  29. }
  30.  
  31. void InputMagnitude() {
  32. //Calculate Input Vectors
  33. InputX = Input.GetAxis ("Horizontal");
  34. InputZ = Input.GetAxis ("Vertical");
  35.  
  36. anim.SetFloat ("InputZ", InputZ, 0.0f, Time.deltaTime * 2f);
  37. anim.SetFloat ("InputX", InputX, 0.0f, Time.deltaTime * 2f);
  38.  
  39. //Calculate the Input Magnitude
  40. Speed = new Vector2(InputX, InputZ).sqrMagnitude;
  41.  
  42. //Physically move player
  43. if (Speed > allowPlayerRotation) {
  44. anim.SetFloat ("InputMagnitude", Speed, 0.0f, Time.deltaTime);
  45. PlayerMoveAndRotation ();
  46. } else if (Speed < allowPlayerRotation) {
  47. anim.SetFloat ("InputMagnitude", Speed, 0.0f, Time.deltaTime);
  48. }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement