How to get the contact collision side/normal in love.physics?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
How to get the contact collision side/normal in love.physics?
How do I get a contact's collision side (with a rectangle) in love.physics? I can't find anything in the documentation, but it should be possible, right?
Re: How to get the contact collision side/normal in love.physics?
I've never used Box2D but if I had to guess:
Every body generates Contact objects when they collide with anything, which you can query with body:getContacts() function. Each contact has a normal, which you can then query with contact:getNormal() function.
Every body generates Contact objects when they collide with anything, which you can query with body:getContacts() function. Each contact has a normal, which you can then query with contact:getNormal() function.
- scissors61
- Citizen
- Posts: 76
- Joined: Fri Jan 08, 2016 10:16 am
Re: How to get the contact collision side/normal in love.physics?
I think you have to create two shapes and fixtures for the same body and then add to each fixture a different userdata info. You could also create two raycasters for each side too.
Re: How to get the contact collision side/normal in love.physics?
Thank you raidho36! I can't believe I didn't notice that in the documentation, that's surprisingly simple. Thanks again!
Re: How to get the contact collision side/normal in love.physics?
body:getContacts is good for "resting" contact, usually when one fixture is standing on top of the other.
A lot of collisions are resolved instantly, so you have to use the PostSolve callback to catch those.
Also, note that the collision normal is not the "collision side" but the axis along which the (non-penetration) impulses were applied.
Tangent/friction impulses are perpendicular to the normal.
A lot of collisions are resolved instantly, so you have to use the PostSolve callback to catch those.
Also, note that the collision normal is not the "collision side" but the axis along which the (non-penetration) impulses were applied.
Tangent/friction impulses are perpendicular to the normal.
Who is online
Users browsing this forum: No registered users and 2 guests