How to know if body is standing/ resting on another body?

I have a player sprite which should only be able to jump when it is on solid grounds. Both the player sprite and the ground are physics objects. What would be the best way to determine if the player is standing on another body/ what would be the best way to appropriately keep a playerSprite.standsOnGround boolean based on recent detected collisions?

(As a workaround I’ll probably just check for near zero y-velocity now, but that doesn’t seem to be perfectly correct.)

Thanks for any help! [import]uid: 10284 topic_id: 4013 reply_id: 304013[/import]

You could check the location of the player and the ground. Then have whatever you want occur if their x positions are aligned and their y positions are such that the player is above the ground or object. [import]uid: 10903 topic_id: 4013 reply_id: 12213[/import]

Get the

vx, vy = myBody:getLinearVelocity()

of your object.

If the value of vy is inside the range of (-5 <= vy <= 5) this means that the object myBody is standing over other object and it’s not moving.

if it’s not that means the myBody object is falling or jumping. To detect the type and name of object that is colliding with use the onCollision Event to get that information [import]uid: 9975 topic_id: 4013 reply_id: 12216[/import]

If the value of vy is inside the range of (-5 <= vy <= 5) this means that the object myBody is standing over other object and it’s not moving.

Yes I figured I could do this as workaround but I guess it wouldn’t work for situations in which the player is at the highest point during a jump, where upwards movement and gravity create a temporary stillstand situation…

You could check the location of the player and the ground. Then have whatever you want occur if their x positions are aligned and their y positions are such that the player is above the ground or object.

Thanks, though I have loads of objects including rotated ones so I will probably have to use the built-in collision detection… [import]uid: 10284 topic_id: 4013 reply_id: 12437[/import]