Achieving the effect shown above isn't nearly as difficult as some might think. By taking a simple model, splitting it up into a ton of pieces, and then replacing the fractured model with the unfractured one upon a death event, this stunning effect can easily be achieved in whatever game you might be creating!
Setup
In order to obtain the assets required for this effect, all you need is something 3D modeled, both in its fractured and whole form.
Fracturing a model is a simple process, utilizing the ability to run custom scripts from 3DS Max and/or Maya to have a program fracture the model at random into a desired number of pieces that we are able to specify.
Below are links to download a 3DS Max and Maya script that when ran will fracture whatever model is currently open in the game.
Once the model has been fractured, save it as a .fbx (or whatever other format you use for your game), and import both the fractured and whole model into Unreal.
In Unreal
Once both models have been imported into Unreal, you might notice that the fractured model imported each individual piece of the fractured mesh as a separate mesh object.
If this has happened, a quick fix is necessary. Create a new actor blueprint, and add an empty object called Root to it. Then, under Root, add in all the pieces of the fractured mesh as static mesh components. Make sure all these pieces have physics enabled.
Once you have the fractured model assembled into a blueprint, scripting out the process of replacing the whole model with the fractured on is quite simple!
Open the blueprint on the whole model. Depending on how you plan to make the object break will determine how the object will know when to replace itself with the fractured model. In this instance, I am using a float variable that keeps track of the current enemy's health to determine when the model should fracture.
Once the condition for the fracture has been met, all you need to do is to spawn in the fractured actor in the same position as the whole actor, and destroy the whole actor. An example of this is shown in the screenshot below:
It's as simple as that! Once health is less than or equal to 0, the fractured model will be spawned at the position of the whole model, and the whole model will destroy itself. All that will be left is the fractured model in the exact position of the once existing whole one, left to be affected by gravity and fall apart!
No comments:
Post a Comment