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

Enemy sprite movement

Feb 16, 2012 at 5:59 PM
Edited Feb 16, 2012 at 6:01 PM

Problem for you all! I assumed it would be simple to create an enemy which when it made contact with a ground body it was reflected as if it was bouncing off it. However I can't seem to find a way for the contact to distinguish between the side ground bodies where you * the x of the Vector2 by -1 or when you hit the top or bottom bodies and times the  y by -1.

The only way I could think of doing this in Farseer is having the userdata of either type declared differently. I hope theres a better way of doing this though because that would mean I have to change lots of other stuff!

Feb 16, 2012 at 6:50 PM

Have you looked at the Restitution property of the bodies? Restitution is the property that controls how much of a 'bounce' your character body will have when colliding with the ground body. You can set the restitution on the ground to be whatever you want or set it on the enemy body to have a consistent 'bounce'. The engine will handle everything else, you shouldn't have to do any manual multiplication to get the desired effect.