- Home /
Earth quake with physics?
I have a lot of small Prefabs with Rigidbody attached. They are all in a pile on a ground.
Now, I would like to simulate an earthquake/bump/explosion below them.
Should I attach a physics force of anti gravitation on the ground object below them or do I have to go through every single of the spawned item and put the physics into each prefab?
I hope for the first, but cant figure out how to do that, without having the objects falling through the ground.
Answer by save · Oct 02, 2011 at 08:14 AM
Depending on how you're able to do the implementation, I'd consider to go Hollywood on the solution - shake the camera and do a series of AddExplosionForce of wide range on all visible rigidbodies.
If the view is set at first person then a series of random values of rotation on X, Y and a slight rotation around Z-axis for the camera will do the trick. Then setting up a series of explosion forces beneath/around your area of rigidbodies together with emitters of smoke, dust and scrap objects will bring a true feeling of chaos.
If you need control over where objects position after the quake then you'd have to animate the event, there's no problem animating them and then attaching rigidbodies after it's done (for instance calling a function for when the object is finished animating to AddComponent(Rigidbody)).
aaah, thats the type of program$$anonymous$$g I was hoping for. AddExplosionForce looks like a solution to me, so thanks for the help.
wooohoo! Got it to work. Couldnt figure out why the sample from the documentation didnt work, until I found Force$$anonymous$$ode - muhahahaha!