I can't figure out why collision event isn't firing.

Topics: Developer Forum, User Forum
Sep 5, 2008 at 2:29 AM
I have an 'actor' object, with various properties (strength, power, etc.)
        public override void CreateBody()
        {
            this.Body = BodyFactory.Instance.CreateRectangleBody(Game1.PhysicsSimulator, 128, 128, 1);
        }

        public override void CreateGeometry()
        {
            this.Geom = GeomFactory.Instance.CreateRectangleGeom(Game1.PhysicsSimulator, Body, 128, 128);
            this.Geom.CollisionEnabled = true;
            this.Geom.CollisionGroup = 1;
            this.Geom.Collision += CollisionTest;
        }

        private bool CollisionTest(Geom geometry1, Geom geometry2, ContactList contactList)
        {
            return true;
        }

So, when I create my actor object, the constructor calls the CreateBody and CreateGeometry methods for each "actor" I create to do things in the game.
However...the collision event never fires, even when one actor moves over the other. I can create multiples, overlay them on each other...no event firing.
I've checked through all forum pages, looking at the collision questions, etc, and haven't found anything that works. Any idea what I could be doing wrong?
Also...looking at the demos (#2 to be specific), I found no event handling in the code. I tried not setting any of the Geom.Collision properties...and still no collision :(

One thing that is happening...gravity works just fine. If I don't make them static, they fall well.



Sep 5, 2008 at 3:02 AM
Ok...after stepping through the collision detection, I found out the deal.
I have to put them in different collision groups. Collision seems to work fine now :)

I have to say, I am very grateful for what seems to be an awesome library. The lack of documentation is kind of a bummer, though.
Coordinator
Sep 5, 2008 at 10:05 AM
Hi jc_lvngstn - Yep, you will need to put them into different collision groups. It is indeed an awesome library and you will find it to be even more awesome when you get to know it better ;)

If you have any requests with features or improvements for Farseer Physics. You are welcome to post them Here.
One of the items on my todo list is more documentation.
Sep 5, 2008 at 5:48 PM
Why can't we create a community documentation page for Farseer... Wiki maybe?  This way the community can update the documentation and the responsibility doesn't fall on one person.
Coordinator
Sep 5, 2008 at 10:50 PM
I have already seen a wiki somewhere.
The problem with wiki's is that it needs somebody to take the step and create some content. Not everyone does this :). The knowledge about the inner works of farseer is also very limited.

I think an official documentation (also in the code as XML comments) would be a very good thing. The reason it's missing (or very limited) is that the owner of the project has very little time. Farseer is also very simple in it self, thats why the documentation was a low priority. :)
Coordinator
Sep 5, 2008 at 10:56 PM
Update:

I found the wiki here from this discussion.
There is also a very limited manual included with the Farseer releases. It would be very happy if someone would contribute to it.
Sep 7, 2008 at 9:39 PM
More people contributing would help... I posted a few but never got around to doing the next few lol