Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. void Start()
  2. {
  3.  
  4. anim = GetComponent<Animator>();
  5.  
  6. }
  7.  
  8. void Update()
  9. {
  10. //CHARACTER JUMP
  11.  
  12. if (Input.GetKeyDown(KeyCode.Space))
  13.  
  14. transform.Translate(Vector3.up * jumpSpeed * Time.deltaTime, Space.World);
  15. }
  16.  
  17. void FixedUpdate()
  18. {
  19. //Character rotation with A and D
  20. var z = Input.GetAxis("Horizontal") * rotSpeed;
  21.  
  22. //Character movement with W and S
  23. var y = Input.GetAxis("Vertical") * speed;
  24.  
  25. //Sprint
  26. if (Input.GetKey(KeyCode.RightShift))
  27. y = y * sprintSpeed;
  28.  
  29. transform.Translate(0, -y, 0);
  30. transform.Rotate(0, 0, -z);
  31.  
  32. //Character animations
  33. anim.SetBool("IsSprint", Input.GetKey(KeyCode.RightShift) && Input.GetKey(KeyCode.W));
  34. anim.SetBool("IsIdle", y < speed && y < sprintSpeed);
  35. anim.SetBool("IsRunning", Input.GetKey(KeyCode.W) && y > 0 && y < 0.0851);
  36.  
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement