If you want to learn how to make a simple state machine in Unity, this tutorial is for you. This tutorial is useful for 3D platformer games and will help you make a fully-functional state machine that will control idle, run and jump animations for your 3D character.
One of the first steps when defining game objects in Unity is to define their states of animation. The most basic states for a playable character are idle, walking, running and jumping. In order to change the default, idle state into a different state, you need to create a state machine.
State Machine is a perfect way to determine when will the animation state be played. Instead of creating animation states and implementing the way that most games use, The state machines can be set up inside the animator window, and by default, you will get this screen. When you create a new animation, the new animation state will appear in the Animator screen.
First, in order to make a State Machine in Unity, you need to create a script.
Inside the script, you need to define an interface. All scripts that will be for animation states will have IState reference instead of MonoBehaviour, so that is what makes these scripts different from other objects in Unity.
If your character cannot jump, it is because your state machine requires a Jump trigger, so make sure that Idle to Jump and Run to Jump animations have Jump trigger in order to make jumping work properly.
Support the Creator of Kozmobot on the social networks!
CHECK OUT MY WEBSITE: http://kozmobot.com
INSTAGRAM: https://www.instagram.com/kozmobot.channel
TIKTOK: https://www.tiktok.com/@kozmobot.channel
Voir sur youtube