Hello,
I have this script that moves a rigidbody along to its local z axis.
The problem is that it disables gravity.
How can I fix this?
rigidbody.velocity = transform.forward * Input.GetAxis("Vertical") * speed * Time.deltaTime;
Hello,
I have this script that moves a rigidbody along to its local z axis.
The problem is that it disables gravity.
How can I fix this?
rigidbody.velocity = transform.forward * Input.GetAxis("Vertical") * speed * Time.deltaTime;
Try this:
var v = transform.forward;
v.y = 0.0;
v.Normalize();
v *= Input.GetAxis("Vertical") * speed * Time.deltaTime;;
v.y = rigidbody.velocity.y;
rigidbody.velocity = v;