How to make a cube turn in the direction it is moving?

So I have a red cube on a plane.
181126-image.png
The cube has a rigidbody and is using force to move. I need it to rotate in the direction it is moving but I am not sure how to. All the solutions I have found apply to things moving with Vector3 (I am not sure if that matters but none of them worked for me). So is there a simple way to make the cube face in the direction it is moving?

    private Rigidbody _rigidbody;
    [SerializeField] private float _movementForce = 10f;

    private void Awake() => _rigidbody = GetComponent<Rigidbody>();
    private void FixedUpdate()
    {
        if (Input.GetKey(KeyCode.W))
        {
            _rigidbody.AddForce(_movementForce * transform.forward);
        }
            
        if (Input.GetKey(KeyCode.S))
        {
            _rigidbody.AddForce(_movementForce * -transform.forward);
        }
            
        if (Input.GetKey(KeyCode.D))
        {
            _rigidbody.AddForce(_movementForce * transform.right);
        }
            
        if (Input.GetKey(KeyCode.A))
        {
            _rigidbody.AddForce(_movementForce * -transform.right);
        }
            
    }

1 Answer

1

Hope the following Post is able to help u :smiley: