This project has moved and is read-only. For the latest updates, please go here.

Help with collision, and how to check for it.

Feb 27, 2011 at 11:16 PM

In my game I have a Body, and on it there can be a variable amount of fixtures. Now I do this to check if it is on the ground!

 private void OnCollision(Fixture fix1,Fixture fix2, Contact cont)

            if (fix2.Body.IsStatic)
                //Pre-eliminary test!

                Vector2 touchPoint = cont.Manifold.LocalPoint;

                Vector2 touchPoint2 = fix1.Body.GetWorldVector(touchPoint);

                if (touchPoint2.Y > (_body.WorldCenter.Y))
                    _onGround = true;


This works to a certain extent, only I want to set the Variable back to false once I stop colliding. That indirectly causes my other problem->

This is when the _onGround is true.

This when it is false.

Currently I am resetting it every Update, that is bad as it causes the variable to "flicker" and is not really a viable solution. This is really blocking me.


Thanks for any help!

Feb 28, 2011 at 7:41 PM
Edited Feb 28, 2011 at 7:42 PM

Hook to the OnSeparation event and set the variable back to false from there.