Using Animation Events to draw a weapon
Another common case in combat mechanics is drawing and sheathing a weapon. In this recipe we will use Animation Events along with a Draw animation to make our character draw and sheath a sword.
Getting ready
To follow this recipe, we need to have a Warrior
character with two animations: Idle
and Draw
. The first one is a standard, looped Idle
animation. The second one is an animation in which our character reaches for their weapon in a sheath attached to the character's belt. We are not using a sheath model here to make the recipe more simple and condensed. You can open the provided example project and go to the Chapter 06 Handling combat\Recipe 06 Using animation events to draw a weapon
directory. There is a Warrior
character in the Example.unity
scene. When you press the space bar, it will draw or sheath a sword. You can find all the necessary animations in the Rigs
directory.
How to do it...
To make a character draw or sheath a weapon, follow these steps...