Advertisement
SizilStank

Untitled

Sep 17th, 2022
1,012
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | Gaming | 0 0
  1. void CalculateMovement()
  2.  
  3.     {
  4.         float horizontalInput = Input.GetAxis("Mouse X");
  5.         float verticalInput = Input.GetAxis("Mouse Y");
  6.  
  7.         Cursor.lockState = CursorLockMode.Locked;
  8.  
  9.         Vector3 direction = (new Vector3(horizontalInput, verticalInput, 0));
  10.         transform.Translate(direction * _speed * Time.deltaTime);
  11.  
  12.         if (Input.GetAxisRaw("Mouse X") == 0)
  13.         {
  14.             _anim.SetBool("PlayerCenter", true);
  15.             _anim.SetBool("PlayerRight", false);
  16.             _anim.SetBool("PlayerLeft", false);
  17.         }
  18.         else if (Input.GetAxisRaw("Mouse X") >= 0.1)
  19.         {
  20.             _anim.SetBool("PlayerRight", true);
  21.             _anim.SetBool("PlayerCenter", false);
  22.             _anim.SetBool("PlayerLeft", false);
  23.         }
  24.         else if (Input.GetAxisRaw("Mouse X") <= -0.1)
  25.         {
  26.             _anim.SetBool("PlayerLeft", true);
  27.             _anim.SetBool("PlayerRight", false);
  28.             _anim.SetBool("PlayerCenter", false);
  29.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement