You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm analyzing contacts in my scene by looping over world.narrowphase.contactEquations for player contacts. The problem is I don't know if the contact will be in bodyA or bodyB, and depending on which it is, I might the get local contact point (in contactPointA as documented here) from the "wrong" body. To calculate the normal for the "right" body, I have to do some translation math for every contact. Is there a better way to always get the local contact point for either body? I can assign an event listener to my specific player body, but I'm wondering if there's a nice way to do it with just reading a generic contact event and not knowing where it came from?
The text was updated successfully, but these errors were encountered:
I guess you always will have to check whether it's bodyA or B, and react differently depending on the result. Maybe you could make it nicer by implementing a handleContact method on each body instance, see the example here: http://www.iforce2d.net/b2dtut/collision-callbacks
When you know which one of the bodies you are interested in you may need to flip the normal. You can do this by just reversing the vector... Alternatively there could be a method on the event object for doing this. If you go for the handleContact method, pass in the reversed vector to it. Or the vector + a multiplier which is -1 or 1.
Other than this I'm out of ideas. I checked the box2d docs but its API don't help with this part either. If you have any suggestions on how to improve the API I'm all ears.
I'm analyzing contacts in my scene by looping over
world.narrowphase.contactEquations
for player contacts. The problem is I don't know if the contact will be inbodyA
orbodyB
, and depending on which it is, I might the get local contact point (incontactPointA
as documented here) from the "wrong" body. To calculate the normal for the "right" body, I have to do some translation math for every contact. Is there a better way to always get the local contact point for either body? I can assign an event listener to my specific player body, but I'm wondering if there's a nice way to do it with just reading a generic contact event and not knowing where it came from?The text was updated successfully, but these errors were encountered: