I created a code so the player can walk forward and left but when i walk forward the object is rotating in that direction but i do not want the object to rotate can someone help me with this?
code:
using UnityEngine;
using System.Collections;
public class WalkScript : MonoBehaviour {
public bool falling = false;
public Rigidbody body;
void Update () {
if(falling) {
body.useGravity = true;
body.isKinematic = false;
}
if(Input.GetKey(KeyCode.W)) {
body.velocity = new Vector3(0, 0, 1);
} else if(Input.GetKey(KeyCode.A)) {
body.velocity = new Vector3(-10, 0, 0);
} else if (Input.GetKey(KeyCode.Space) && falling == false) {
body.velocity = new Vector3(0, 10, 0);
falling = true;
}
}
void OnCollisionStay() {
falling = false;
}
}