- Home /
ExplosionForce On Instantiated Object
Hello.
I have a structure that once hit by another collider it will Instantiate a broken version of the structure in its place, Every thing works fine. All pieces of the broken structure have colliders and rigidbodys then the structure crumbles as intended.
I have a RPG that fires a missile, Once missile hits another collider it explodes with AddExplosionForce obviously causing anything with a rigidbody to be effected.
The missile hits the structure > Missile Explodes with force > Structure Instantiates then crumbles to the ground not effected by the Missiles explosive force.
The Missile should send the broken structure pieces flying all over the place but it dose not.
Is there a way to fix this problem? Sorry for the essay Thanks.
I added a delay to the explosion force but its far too noticeable, There has to be another way
I think that perhaps the force is added to the structure before the broken version is instantiated, meaning that there will be no force acting upon the broken structure. $$anonymous$$aybe a solution would be to wait one frame to add the explosion force if that's possible?
Thanks for the reply, I did wait 1 frame but it was incredibly noticeable, The missile would hit, you would see structure falling for a split second, then out of nowhere the pieces fly all over the place, It's too much of a delay, Couldn't work out how to speed it up so its more of a , Hit > Switch > Bang > Debris
Pass the variables in the explosion force to the script that instantiates the broken structure. Then when that script instantiates the broken structure, add explosion force to each piece.
if you have a frame rate of 60fps it doesn't seem like waiting a frame would be that much of a difference.
However, a another possible solution would be to forget AddExplosionForce, and manually add force to the objects near the source of the explosion. By looping through the newly instantiated debris objects near the source and adding force to each one in an outward direction from the source, perhaps you could simulate an explosion adequately?
Answer by DynamicPrgm · Jan 22, 2014 at 03:36 PM
Here's the answer. If you have a frame rate of 60fps it doesn't seem like waiting a frame would be that much of a difference.
However, a another possible solution would be to forget AddExplosionForce, and manually add force to the objects near the source of the explosion. By looping through the newly instantiated debris objects near the source and adding force to each one in an outward direction from the source, perhaps you could simulate an explosion adequately?
Your answer
Follow this Question
Related Questions
Rigidbody stuck in colliders when moving and ricosheting. 0 Answers
OnCollisionEnter but have colliding object not move the object it collides with 1 Answer
What does rigidbodies sleeping have to do with collision detection? 0 Answers
handling collision with two objects of the same tag 1 Answer
Collisions between two rigidbody's and scripting collisions problem 2 Answers