开发者

How to detecting overlap in Box2d objects

I'm trying to figure out how to detect if one box2d shape is overlapping another. I can't use the normal collision detection because one of the objects is not active and not part of the physics sim yet. This is an object that the user can move around the screen with the mouse and when they let up on the button, the object is added to the sim (via SetActive).

The problem is that user can move this object right on top of another object and when they let up on the mouse button, it's added and produces a jarring collision and 开发者_JS百科often gets stuck inside the other object.

So, what I'm looking for is a way to know if one object is overlapping another so I can prevent the 'dropping' of the user controlled object.

I can loop over all the objects in the sim and check against this one user controlled object, but I see no API to detect this kind of overlap.

Thanks


You could add it to the sim as a sensor so it doesn't have any interaction with the other bodies, but you can still get BeginContact/EndContact events for it. Then when it is dropped all you have to do is change the sensor status.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜