Adding rigid props to animated characters
If you haven't included a sufficient number of props for your character when modeling and animating it, you might want to give her the chance to collect new ones at runtime. In this recipe, we will learn how to instantiate a GameObject and assign it to a character while 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. There is also a Texture named texture_pickupBadge.png.
The files can be found in the 09_06
folder.
How to do it...
To add a rigid prop at runtime to an animated character, follow these steps:
- Create a new 3D project and import the Props Unity Package and the
texture_pickupBadge.png
Texture. - Then, from the Project panel, open the
mecanimPlayground
level. - From the Project panel, add the badge prop to the scene by dragging it into the Hierarchy.
- Make the badge a child of the
mixamorig:Spine2
Transform...