Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private void PlayerController()
- {
- if (touchingGround== true)
- {
- if (Input.GetKey(KeyCode.W))
- {
- GetComponent<Rigidbody>().AddRelativeForce(Vector3.forward * speed);
- }
- if (Input.GetKey(KeyCode.S))
- {
- GetComponent<Rigidbody>().AddRelativeForce(Vector3.back * speed);
- }
- if (Input.GetKey(KeyCode.D))
- {
- GetComponent<Rigidbody>().AddRelativeForce(Vector3.right * speed);
- }
- if (Input.GetKey(KeyCode.A))
- {
- GetComponent<Rigidbody>().AddRelativeForce(Vector3.left * speed);
- }
- if (Input.GetKeyDown(KeyCode.Space))
- {
- GetComponent<Rigidbody>().AddForce(Vector3.up * speed);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement