Physics - How to tell if standing on a platform?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
Greninjask
Prole
Posts: 6
Joined: Sun Mar 20, 2016 5:11 pm

Physics - How to tell if standing on a platform?

Post 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?
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

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

Post 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
User avatar
erasio
Party member
Posts: 118
Joined: Wed Mar 15, 2017 8:52 am
Location: Germany

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

Post 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!
User avatar
ivan
Party member
Posts: 1915
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

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

Post 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()".
User avatar
erasio
Party member
Posts: 118
Joined: Wed Mar 15, 2017 8:52 am
Location: Germany

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

Post 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.
Greninjask
Prole
Posts: 6
Joined: Sun Mar 20, 2016 5:11 pm

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

Post by Greninjask »

Thanks for the responses! That article is really helpful, I'll give it a shot.
Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests