Asking Box2d if a collision happened
Posted
by Rosarch
on Stack Overflow
See other posts from Stack Overflow
or by Rosarch
Published on 2010-03-25T21:53:32Z
Indexed on
2010/03/26
15:23 UTC
Read the original article
Hit count: 570
I'm using Box2dx (ported to C#; optimized for XNA). It handles collision resolution, but how can I tell if two objects are currently colliding?
This is the function I'm trying to write:
public bool IsColliding(GameObjectController collider1, GameObjectController collider2)
Where collider1.Model.Body
is the Box2d Body
, and collider1.Model.BodyDef
is the Box2d BodyDef
. (The same goes for collider2
, of course.)
UPDATE: Looks like contact listeners or this could be useful:
AABB collisionBox;
model.Body.GetFixtureList().GetAABB(out collisionBox);
Why does GetFixtureList()
return one fixture?
© Stack Overflow or respective owner