Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void Start()
- {
- anim = GetComponent<Animator>();
- }
- void Update()
- {
- //CHARACTER JUMP
- if (Input.GetKeyDown(KeyCode.Space))
- transform.Translate(Vector3.up * jumpSpeed * Time.deltaTime, Space.World);
- }
- void FixedUpdate()
- {
- //Character rotation with A and D
- var z = Input.GetAxis("Horizontal") * rotSpeed;
- //Character movement with W and S
- var y = Input.GetAxis("Vertical") * speed;
- //Sprint
- if (Input.GetKey(KeyCode.RightShift))
- y = y * sprintSpeed;
- transform.Translate(0, -y, 0);
- transform.Rotate(0, 0, -z);
- //Character animations
- anim.SetBool("IsSprint", Input.GetKey(KeyCode.RightShift) && Input.GetKey(KeyCode.W));
- anim.SetBool("IsIdle", y < speed && y < sprintSpeed);
- anim.SetBool("IsRunning", Input.GetKey(KeyCode.W) && y > 0 && y < 0.0851);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement