Hello!
I’ve got this line of code: rigidbody.velocity = new Vector3(0, 10f, 0);
It almost works as intended. However, it’s only supposed to change the Y value (10f).
How can I make the X and Z value be unchanged, while changing the Y value?
Hello!
I’ve got this line of code: rigidbody.velocity = new Vector3(0, 10f, 0);
It almost works as intended. However, it’s only supposed to change the Y value (10f).
How can I make the X and Z value be unchanged, while changing the Y value?
Unity - Scripting API: Rigidbody.constraints.
Although, your change of the velocity should not change the x or z of the object, unless there is another force than gravity and initial velocity. Constant Force, another object making the first one bounce ?
To be sure x and z velocity don’t change, get the old velocity values and pass them on:
rigidbody.velocity = new Vector3 (rigidbody.velocity.x, 10f, rigidbody.velocity.z);