Python - How to program a jump using physics?

Hello, I am programming moving from buttons and I have a problem with programming the jump. Please advise.

Hi @Medard , I would use in this case:

item.physics.apply_impulse(Vector3.zero, Vector3(0,0,25));

The first vector indicated the origin (local) and the second vector indicating the velocity of the jump, this will “push” the object with the inidicated velocity which in this case is probably your best bet or;

item.physics.velocity = Vector3(0,0,6);

To set the velocity of the item directly, difference being that this one will set the velocity to the number indicated. Which can be annoying because the x and y velocity will now be set to 0 unless you set them to the current x and y velocity respectively; As well as the jump not being able to increase the z velocity past the indicated number (usually not desirable to begin with, but you would have to program a defense to stop infinite jumping on both options either way).

1 Like

Thank you for the solution. Now objects jump as they should.

1 Like