1
votes

I have implemented b2ContactListener for detecting collisions. I have a world with gravity equal to (0,0) and I have a dynamic body which is not a sensor and Kinematic bodies which are sensors. The collision between them is not being registered strangely. But when I make the kinematic bodies non-sensors, then collision is being detected and dynamic body changes the position because of the collision. Could it be because I move both dynamic and kinematic bodes by using body->SetTransform(...) function? Or I am missing something else?

1
Did you read box2d.org/manual.pdf p.30 (Sleep Parameters) and p.31 (Activation)? - wonko realtime
Please define what you mean by 'collision is not being registered'. Does your contact listener get a BeginContact callback? If you want to have collision response ('body changes position because of the collision') then both bodies must not be sensors. Sensors do not have collision response. - iforce2d
@iforce2d The problem was that BeginContact callback had not been called. - Narek

1 Answers

1
votes

I have fixed the problem: I have changed sleeping setting to m_world.SetAllowSleeping(false); and it worked. The problem was the following: as far as there was a no physics simulation, and I have moved the object by calling SetTransform function the objects were sleeping. On the other hand sleeping objects cannot register collisions. Hence, when I didn't allow sleeping it started to call BeginContact callback.