Advertisement
Guest User

Control

a guest
Mar 27th, 2017
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1.     void FixedUpdate ()
  2.     {
  3.         float moveHorizontal = Mathf.Cos(cam.transform.rotation.eulerAngles.y * Mathf.Deg2Rad) *Input.GetAxis("Horizontal") + Mathf.Sin(cam.transform.rotation.eulerAngles.y * Mathf.Deg2Rad) * Input.GetAxis("Vertical");
  4.         float moveVertical = Mathf.Cos(cam.transform.rotation.eulerAngles.y*Mathf.Deg2Rad)*Input.GetAxis("Vertical") - Mathf.Sin(cam.transform.rotation.eulerAngles.y * Mathf.Deg2Rad) * Input.GetAxis("Horizontal");
  5.         Vector3 movement = new Vector3(moveHorizontal, 0.0f,moveVertical);
  6.         Debug.Log(movement);
  7.         rb.AddForce(movement.normalized*speed);
  8.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement