Advertisement
Guest User

Untitled

a guest
Sep 2nd, 2015
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.89 KB | None | 0 0
  1.                    
  2.     private void PlayerController()
  3.     {
  4.         if (touchingGround== true)  
  5.         {
  6.             if (Input.GetKey(KeyCode.W))
  7.             {
  8.                 GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * speed);
  9.             }
  10.             if (Input.GetKey(KeyCode.S))
  11.             {
  12.                 GetComponent<Rigidbody>().AddRelativeForce(Vector3.back * speed);
  13.             }
  14.             if (Input.GetKey(KeyCode.D))
  15.             {
  16.                 GetComponent<Rigidbody>().AddRelativeForce(Vector3.right * speed);
  17.             }
  18.             if (Input.GetKey(KeyCode.A))
  19.             {
  20.                 GetComponent<Rigidbody>().AddRelativeForce(Vector3.left * speed);
  21.             }
  22.             if (Input.GetKeyDown(KeyCode.Space))
  23.             {
  24.                 GetComponent<Rigidbody>().AddForce(Vector3.up * speed);
  25.             }
  26.         }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement