Platforming Help

I cant figure out how to make an entity only jump when on the ground i can apply forces when the up key is pressed but then the character just flies

Welcome to Playcanvas!

You can check this helpful guide on impulses and forces:

Instead of applying a constant force on an object, you can give it an impulse. Its like a single punch, instead of constant push:

this.entity.rigidbody.applyImpulse(0, 10, 0);

This will apply an impulse with a power of 10 on Y axis (vertical). Impulses should not be called every frame, so make sure you don’t call it from the .update(dt) method, but from the method that is called when a key is pressed.

1 Like

I did look a that and i am using as my base but i need to be able to check if the players on ground and if true have the player jump

But i cant figure out how the collision works i checked the api but it didnt help

There are a few options here and really depends on your game design.
One of the options is to check the current height of the player and see if it is on the same height as the ground. You may find some other options in this thread:

1 Like