SHARE
TWEET

Untitled

a guest Jul 18th, 2019 59 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top