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

Simulate an explosion

Oct 12, 2007 at 12:52 AM
Would it be possible with farseer to simulate forces like explosions??? I'm trying to do this for a grenade launcher. Basically the grenade is throwned as regular body object but after 2-3 seconds it explodes. I was thinking of maybe just creating a new circle body (invisible to the screen) and circle geometry and expand it's radius to simulate the force and push objects away. At the same time I could check what entities are in contact with the circle body and apply a certain amount of damage, depending on the radius (the smaller the radius is when a player touches it, the more damage it does).

Does that make any sense?? Is there any better way of doing this??

Oct 12, 2007 at 11:36 AM
Edited Oct 12, 2007 at 11:37 AM
The abstract Controller class (think ForceConroller) was designed just for such a scenario. You will need to implement the abstract method "ApplyForce" yourself, but this is the way to go.

You would need to create an ExplosionController class that derived from Controller. Then, possibly have a list of bodies that can be affected by explosions in this class. In the ApplyForces method, calculate a force to apply to each of the bodies based on the position of th explosion.

On other thing. You could also use ApplyImpulse on the bodies within the ApplyForces abstract method.