i'm trying to get a callback when two entities collide each other. I read the right way to do this is to use (Entity).addEventHook but i' can't make it works!
this is my code:
Where "m_PhysicsBody" is a CompoundBody with one ore more entity inside. So, when i make two m_PhysicsBody collide each other no events are fired!
What could be the problem?
The collision-related events currently operate on the sub-bodies which are actually doing the colliding. If you listen to the compound body only, you'll miss the subbody reports. I think for the next version I'll send event notifications from the parents as well as the colliding children to make it easier.
Also, the EventHandlerControllerCreated event will fire when bodies come close to each other; for precise collision event throwing, you could use EventHandlerInitialCollisionDetected.
I get now events for my subbodies when I do it exactly like the code above. I get events when I use just a single Entity, but as soon as en entity is a subbody, no events are generated anymore for that entity. Do I need to do anything else? I just create the subbodies, add them to a List, then create the CompoundBody with that list as argument for the constructor, then after that I'm doing the thing above. I never Update or do something with the subbodies. The subbodies are also not added to the space which should be ok?
--> Why I get no collision events for the subbodies?
If it isn't already, move your addEventHook statement after the compound body is added to the space. There's an inconsistency in how the add method deals with normal eventful entities and compound eventful entities that's fixed in the next version.