Pushing objects away due to explosions

User avatar
chaosavy
Posts: 29
Joined: Wed Nov 11, 2009 9:09 pm

Pushing objects away due to explosions

Post by chaosavy »

Curious:

I want objects to be "blown away" due to a nearby explosion. Is there something like this included? Sort of a reverse gravity?


Or should I do apply linear force and apply angular force to objects within the blast radius to simulate this myself?



thanks
User avatar
dphil
Posts: 237
Joined: Tue Jun 29, 2010 10:27 pm

Re: Pushing objects away due to explosions

Post by dphil »

You would need to do this yourself. One common way would be to create a ghost sphere representing the blast, and iterate over all objects inside it an apply forces correspondingly, perhaps based on the distance from the centre of the sphere (the blast origin). This is a "simple" approach. To get fancier, you could perhaps do something like casting a ray from the blast origin to one or more points (such as the centre or bounding box corners) on each object in the blast radius to determine if that object is "visible" to the blast, and not shielded behind something else (in which case you might not want to apply any forces). You could also use the distance of the raycast hits from the blast origin - and their local position on the object - to apply varying forces across an object (which would result in linear+angular velocity).
User avatar
chaosavy
Posts: 29
Joined: Wed Nov 11, 2009 9:09 pm

Re: Pushing objects away due to explosions

Post by chaosavy »

thanks! :)