redOrange

PlayerMovement.cs

Sep 23rd, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | None | 0 0
  1. public void Start()
  2. {
  3.       fixedJoystick = GameObject.Find("Joystick").GetComponent<FixedJoystick>();
  4. }
  5.  
  6. public void Update()
  7. {
  8.         mov = new Vector3(SimpleInput.GetAxis("Horizontal") * speed, 0, SimpleInput.GetAxis("Vertical") * speed);
  9.  
  10.         playerController.Move(mov * speed * Time.deltaTime);
  11.  
  12.         if (Vector3.Angle(Vector3.forward, mov) > 1f || Vector3.Angle(Vector3.forward, mov) == 0)
  13.         {
  14.             Vector3 direct = Vector3.RotateTowards(transform.forward, mov, speed, 0.0f);
  15.             transform.rotation = Quaternion.LookRotation(direct);
  16.         }
  17. }
Advertisement
Add Comment
Please, Sign In to add comment