Page 1 of 1

Physics - How to tell if standing on a platform?

Posted: Wed Jul 05, 2017 12:38 am
by Greninjask
I'm hoping there is a simple answer to this,

Using love.physics, I have two bodies in my game: a player, and a platform. I want to make it so the player can only jump when the platform is beneath him. What is the best way to verify that the platform's collider is right beneath the player's?

Re: Physics - How to tell if standing on a platform?

Posted: Wed Jul 05, 2017 4:48 am
by ivan
The most reliable way I have found is to check if the player is being "pushed" along the axis of gravity:
http://2dengine.com/doc/gs_physics6.html

Re: Physics - How to tell if standing on a platform?

Posted: Wed Jul 05, 2017 6:24 am
by erasio
ivan wrote: Wed Jul 05, 2017 4:48 am The most reliable way I have found is to check if the player is being "pushed" along the axis of gravity:
http://2dengine.com/doc/gs_physics6.html
Oh wow. That is a fantastic guide!

Not my question but thanks a lot!

Re: Physics - How to tell if standing on a platform?

Posted: Wed Jul 05, 2017 12:16 pm
by ivan
erasio wrote: Wed Jul 05, 2017 6:24 amNot my question but thanks a lot!
Your question is re-stated and answered in the article as:
"Is the body pushed along an axis?"
Unfortunately, the example code is not designed for Love2D,
but you can easily write your own version using "body:GetContactList()".

Re: Physics - How to tell if standing on a platform?

Posted: Wed Jul 05, 2017 1:21 pm
by erasio
ivan wrote: Wed Jul 05, 2017 12:16 pm Your question is re-stated and answered in the article as:
"Is the body pushed along an axis?"
Unfortunately, the example code is not designed for Love2D,
but you can easily write your own version using "body:GetContactList()".
Haha. My friend. I meant this literally wasn't my question. As in not my thread :ultrahappy:

Just think that page is fantastic.

Re: Physics - How to tell if standing on a platform?

Posted: Wed Jul 05, 2017 11:31 pm
by Greninjask
Thanks for the responses! That article is really helpful, I'll give it a shot.