Basic Hand Animations
Objective: attaching basic animations to our player’s hands!
You have either created or obtained some basic hand animations and now you want to attach them to your players hands. You can find hand animations from the Unity store, or Filebase depending on your preferences.
If you select the prefab you have for your hand, in the inspector you will notice an animator component that it is looking for a Runtime Animator Controller. We need to create this. Right click in the project view where you want to create this then select Animation Controller.
Creating this controller also opens the Animator window. In here you will be able to create different states of animation as well as transitions from one state to another.
Right click in the negative area in the animator window and create an empty state. This will become our open hand animation.
You will notice a connection from the entry state to the new state. This means the open state is the default state that the animator will navigate to. So, when you start your game the position of the hand will be in the open position.
With the open state selected, in the inspector the top option is motion. This is the animation you want to use for your open hand. Select the animation and drop it into this option.
Now we want to repeat this process for the closed animation. Create a state and add the animation to the motion option.
We now need to create transitions going from open to closed, as well as, closed to open.
If we were to leave it here, you hand would automatically cycle through the animation states opening and closing the whole time. Instead, we want to control transitions. To do this we need to select the transitions and remove the “Has Exit Time”
Now we need to make two trigger Parameters. These are going to be when we have Selected an object(grabbed), and Deselected(let go).
Select the transition from Open to Closed and in the inspector, we can now add a condition. This condition will be Selected.
Now repeat for the transition from Closed to Open and add the Deselected condition.
We are almost done, now select the right-hand controller in the Hierarchy and under the XR Controller in the inspector we are going to type in the name of our Parameters into the ‘Model Select/Deselect Transition.’
Now when you open you start the game you hand will open or close when you press the grip button and open when you let go.
Don’t be afraid to experiment with your animations, and I’ll see you in the next tutorial!