I have set up a jumping mechanic, but when the object jumps it only jumps on the y axis. What do I need to replace the “0” with to make the object jump in the direction it is moving. Right now it only jumps up.
var rigidbody = gameObject.GetComponent<Rigidbody>();
rigidbody.velocity = new Vector3(rigidbody.velocity.x, jumpHeight, rigidbody.velocity.z);
Note however that “jumpHeight” is not actually jump height, even if that’s what you call it. It should more accurately be called “verticalJumpSpeed” because that is how you literally use it. Its units would be distance per time, whereas the units of jump height would just be distance. The actual height of the jump will depend on the parabolic curve created by the combination of the vertical jump speed and the strength of gravity.