Adding rigid props to animated characters
In case you haven't included a sufficient number of props to your character when modeling and animating it, you might want to give her the chance of collecting new ones at runtime. In this recipe, we will learn how to instantiate a GameObject and assign it to a character, respecting the animation hierarchy.
Getting ready
For this recipe, we have prepared a Unity Package named Props
, containing a basic scene that features an animated character and a prefab named badge. The package can be found inside the 1362_07_06
folder.
How to do it...
To add a rigid prop at runtime to an animated character, follow these steps:
Create a new project and import the
Props
Unity Package. Then, from the Project view, open the mecanimPlayground level.From the Project view, add the badge prop to the scene by dragging it onto the Hierarchy view. Then, make it a child of the mixamorig:Spine2 transform (use the Hierarchy tree to navigate to MsLaser | mixamorig:Hips | mixamorig...