This project has moved. For the latest updates, please go here.

Update OnCollision with a Sensor and React to Seperation

Topics: Developer Forum, Project Management Forum, User Forum
Feb 19, 2015 at 2:42 PM
i've got a Sensor for a Fish. If Someone Collides with the Sensor the Fish try to swim away.
if the Player is out of the Sensor the Fish should swim his normal random way.
Case 1. Set OnSensorCollision returns true; the On Seperation Event works but the Fish did't change his direction if you follow him in his Sensor
Case 2. Set OnSensorCollision returns false; the On Seperation Event don't works but the Fish change his direction if you follow him in his Sensor.

I need a contineous Detection with a Seperation Event

            Vector2 TargetDirection; 
            Sensor.OnCollision += OnSensorCollision;
            Sensor.OnSeparation += OnSensorSeperation;     

   bool OnSensorCollision(Fixture A, Fixture B,Contact contact)
                    movementPattern = MovementPattern.Scared;
                    TargetDirection = A.Body.Position - B.Body.Position;
                    return __true__;

        void OnSensorSeperation(Fixture fixtureA, Fixture fixtureB)
            movementPattern = MovementPattern.RandomSwim;