- Home /
Explosion with Broken Parts Unity3d
Hello everyone..
I want explosion on 3d character model. On explosion i want characters body parts to be exploded in random direction.
But i have no idea about how to do such type of explosion effect. Please help me, what kind of script should i write?
Thanks in advance for your support and help.
Answer by Fattie · Sep 17, 2013 at 08:04 AM
It's a common thing:
(1) have your model "normal" (perhaps a prefab, if you work that way)
(2) have your model "after death" (perhaps a prefab, if you work that way)
At the moment of death, in fact SWAP from prefab A to prefab B
This is very common in video games. Often when you play a game, the character is swapping from one version to another. Even though it LOOKS THE SAME, it's a totally different prefab for a different purpose.
Now in this situation. When you swap to "prefab dead". That new prefab IS IN FACT, MADE IN SMALL PIECES. It might have say 7 pieces.
Once again -- IT IS A TOTALLY UTTERLY DIFFERENT PREFAB.
So, you swap to the "dead" prefab. And then, since it has seven pieces, you have an animation, forces, or whatever you want to make them blow apart.
It's actually a big part of video games and has a lot of engineering details associated. (For example, it's often not so easy to swap from prefab A to prefab B - you have to match all the positions etc.)
So that's the basic idea and that's exactly how you do it.
For detailed questions on this ask another question or search on here for 100s of QA about it.
yeah sir but how will i start animation from explosion point.? I have created broken parts prefab and i have destroyed my main game object now i am planning to do animation like blowing parts in air from that point. And it is 2d scene so my object is moving in x-y plane.
Sure, are you using physics? So, rigidbody and colliders?
IF SO, simply set a velocity (rigidbody.velocity) for each part, so one line of code for each part. Play it and see if it looks good. Adjust until it looks good.
If you are not using physics at all.
Very simply, you will have to make an animation for each part (just use the "animation" screen in Unity). So, the arm would fling up in the air and then down to the ground. You would do an animation for each one.
That's all there is to it.
You must tick this question as closed and then do not hesitate to ask a new different question about animating explosions.
What you were asking here was about swapping to a new model which is a key technique in video games.
You must now close this question please, thanks. Do not hesitate to ask a new question.
Your answer
![](https://koobas.hobune.stream/wayback/20220613114324im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Collision problem 0 Answers
Creating a draggable object - and defining areas. 1 Answer
Adding collision detection to movement script... 1 Answer
Collision will not work 1 Answer