Hello everyone, i have managed to make my cube move with WASD and Space to jump but when it does move my cube like to flip and rotate, i don’t want that to happen. How would i stop him from doing that?
using UnityEngine;
public class playermovement : MonoBehaviour
{
public Rigidbody rb;
public float forwardForce = 50f;
// Use this for initialization
private void Start()
{
Debug.Log("hello world");
rb = GetComponent<Rigidbody>();
}
private void FixedUpdate()
{
if (Input.GetKey(KeyCode.A))
rb.AddForce(Vector3.left * forwardForce);
if (Input.GetKey(KeyCode.D))
rb.AddForce(Vector3.right * forwardForce);
if (Input.GetKey(KeyCode.W))
rb.AddForce(Vector3.forward * forwardForce);
if (Input.GetKey(KeyCode.S))
rb.AddForce(Vector3.back * forwardForce);
if (Input.GetKey(KeyCode.Space))
rb.AddForce(Vector3.up * forwardForce);
}
}