3
\$\begingroup\$

I'm stuck trying to get these cube objects to explode into chunks when destroyed in Unity. I've set up a physics sim in Blender of the effect I want, originally planning to replace the unbroken GameObjects with this fragmented one coupled with the explosion animation upon destruction. I guess it's not that simple.

enter image description here

I've tried "Bake to Keyframes" in blender and exporting as an FBX, but Unity imports each individual fragment with its own Animator/Avatar and a crazy amount of animations, which is almost useless. Any better ways to go about this?

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

From this, I can see two solutions. Either you could recreate the effect in Unity, thus negating the problem entirely and leading to potentially cooler results, or you could just fix and export the thing.

Reanimate in Unity

Rather than trying to get the object and its animations to export from Blender into a usable format, you could export the model and reanimate it in unity. This would not only involve slightly less hassle, but it might even create a cooler effect, since you could use real-time physics and collisions in-game.

First, export the model, and import it into Unity. You may want to parent the little pieces of the cube to an empty before or after the export so you can keep track of them more easily.

Once the model is in Unity, you could use Unity's built in physics to create the effect in real time. Add mesh colliders and rigidbodies to each piece of the cube, and make a script that launches each piece away from the cube when it needs to explode.

Just Export It!

If you really need to have the animation that you made in Blender, then you need to clean up the model some before you can export it. The current problem is that each piece of the cube isn't connected, but is instead its own separate object. This means that Blender has made a separate animator for every piece of the cube.

To fix this, you need to create an empty axis object and parent all of the pieces to this object. Then, bake the animation to keyframes on the axis object. Make sure that you remove any keyframes on the pieces before baking. This should fix the issue, so try exporting the file again.

If it still doesn't work, then you will have to get destructive with your work. You will need to delete the animations off the pieces and recreate them as a single animation, with the empty axis as the animator. Since this completely deletes the animation, you may just want to recreate the effect in Unity if you reach this point.

Either Works

I would recommend recreating it in Unity, but it entirely depends on your needs. If this is part of a character's animation, or if you are on a very tight performance budget, then freely moving physics objects may not be the best option. But if you just want to use this as an interesting effect, or even if this is in a cutscene, then Unity's physics may give better results.

\$\endgroup\$
0
2
\$\begingroup\$

What solved the problem for me was: select all the parts then Object->Rigid Body->Bake to KeyFrames. Export as FBX with Animation option selected and selected objects. The parts will be automatically attached on one parent. Note I am using a FBX exporter add on called Better FBX but should work with the regular FBX exporter

enter image description here

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .