Collision not detected

Topics: User Forum
Oct 23, 2009 at 12:55 AM


I can't get the collisions to work. Here are my settings:

- All non-static objects are sensors.

- All non-static objects have OnCollision event.

- NarrowPhaseCollider is SAT.

There is one extra, maybe even unorthodox, thing i am doing. I'm disposing animated object's geom and body every frame and adding a new set. The way I had setup my program is:
- Each frame contains various sprites.

- Each sprite contains one "body" (vertices defining its collision vectors)

- Each frame has new sprites and so new "bodies".

In order to get the relevant collision vectors for the object, I have to change its vertices but not just vertices, because the sprite in the current frame may not exit in the next one. Its complicated situation which I can't think of a better way to handle.

ps. I do update the position of the bodies.

Oct 23, 2009 at 9:44 AM

Take into acount that sensors are also static objects. And static geoms don't collide between them (the don't move either).

Can you post your OnCollision event?


Oct 23, 2009 at 6:01 PM

The OnCollision Event is never triggered, I just added a line for test but here:

public bool OnCollision(Geom geomA, Geom geomB, ContactList contactList)
            return true;


geom = GeomFactory.Instance.CreatePolygonGeom(Global.PhysicsSimulator, body, frame.Sprites[spriteIndex].Body, 0);
geom.IsSensor = true;
geom.OnCollision += new CollisionEventHandler(OnCollision);

I was told to do this by genbox:

"You can turn off the physics by setting Geom.IsSensor = true. This way you will have to move all the objects yourself. You can then use the OnCollision event to detect when something has collided."

Because I only want collision detection.

Thank you.

Oct 23, 2009 at 8:14 PM

Instead of setting the geom.IsSensor = true, try assigning geom.CollisionResponseEnabled = false and see if that works.

Oct 23, 2009 at 8:24 PM

Woot! Thanks dude. It works :)