How does rigidbody velocity works?
I read the documentation, and it says:
The velocity vector of the rigidbody. It represents the rate of change of Rigidbody position.
So, there it comes this example:
if (Input.GetButtonDown("Jump"))
rb.velocity = new Vector3(0, 10, 0);
But...I still can't understand very well how does this works. Does the 10 means the object moves in the Y axis until its velocity reaches 10? So yeah, I can't honestly understand how the velocity of a rigidbody works.
Answer by markythemurloc · Jun 22, 2020 at 08:03 AM
Hey! Lets try to simplify things.. A rigidbody's velocity affects the "rate of change of Rigidbody position", this means that the rigidbody's position will be affected by the velocity in each frame, until you declare otherwise. rb.velocity = new Vector3 (0, 10f, 0);
- This means that rb's X velocity will be 0 units per second, Y velocity will be 10 units per second, and Z velocity will be 0 units per second.
Once you set a velocity to a rigidbody, it will keep moving at that velocity until you tell it otherwise.