Game Development Community

Farseer FSGeomComponent OnCollision delegate [solved]

by Josh Neider · in Torque X 2D · 11/15/2010 (4:05 am) · 1 replies

We're doing some testing with farseer and I'm trying to use the FSGeomComponent OnCollision.

I've created my CollisionEventHandler and it shows up in the builder just fine and I'm calling a function and I can do something like...
[TorqueXmlSchemaType]
public static CollisionEventHandler TakeDamage
{
     get { return takeDamage; }
}


public static bool takeDamage(Geom geometry1, Geom geometry2, ContactList contactList)
        {
            if (geometry2.Owner.Physics.VelocityX > 15f)
            {
                geometry1.Owner.MarkForDelete = true;
            }

            return true;
        }

Instead of marking the object for delete I would love to access another component that's in my Game on that geometry1 owner and call a function within it... but since Torque2D cannot have a reference to my game (circular dependency) I'm not sure how I can do much in this function to the object... or in general for farseer collisions.

Any help would be greatly appreciated.

Josh

#1
11/15/2010 (4:45 am)
Ok, I figured this out :-) ... I need to put the above code somewhere in my Game, not in the FSGeomComponent itself... and just have:

using FarseerGames.FarseerPhysics.Collisions;