Hi guys, I was wondering if there's a way to get collision coordinates ( not center of either colliding bodies, but the place of actual impact ) from a onPostSolve(event) ? I tried event.x and event.y , but they return a nil value.
@Mells, yes that have been implemented. Going from the top of my head, but I think that every collision event has a contact property, which is a b2.Contact instance as in:
--define begin collision event handler functionfunction scene:onBeginContact(e)--b2.Contact object from the docsprint(e.contact)end
You can then use contact object to retrieve manifolds (contact points) or even reset collision friction and restitution.
You can then use contact object to retrieve manifolds (contact points) or even reset collision friction and restitution.
@ar2rsawseen Thank you This is what I have so far (I had to dig to find relevant informations) :
local manifold = event.contact:getManifold()for i, j inpairs(manifold.points)dofor a, b inpairs(j)doprint(a, b)-- normalImpulse number-- localPoint table-- tangentImpulse numberfor c, d inpairs(j.localPoint)doprint(c, d)-- y-- xendend
I am not sure that those x, y are the ones I was looking for? I wanted to get the coordinates of the collision, but I got some coordinates that are local to...? I have no idea.
Is iterating through the table the more direct way to get those datas? I feel that I'm missing a simple way but can't find anything relevant in the API.
Edit : I really can't see how I can find the collision's global coordinates.
@Mells for global coordinates you should use :getWorldManifold() and the points provided should be global to box2d world I don't remember the exact structure now, but you can always print it out to see the structure of the table:
Comments
Likes: RogerT
I was wondering if this has been implemented or if an alternative to get collision coordinates exists?
Going from the top of my head, but I think that every collision event has a contact property, which is a b2.Contact instance as in:
Likes: DungDajHjep
Thank you
This is what I have so far (I had to dig to find relevant informations) :
I wanted to get the coordinates of the collision, but I got some coordinates that are local to...? I have no idea.
Is iterating through the table the more direct way to get those datas?
I feel that I'm missing a simple way but can't find anything relevant in the API.
Edit : I really can't see how I can find the collision's global coordinates.
Likes: DungDajHjep
I don't remember the exact structure now, but you can always print it out to see the structure of the table:
Likes: DungDajHjep