![]() To create a transition, make a right click on the source state. TransitionsĪ transition is a link between two states, telling to the state machine how we go from one to another. (Sadly, the editor doesn’t differentiate triggers from booleans visually) You may want a different animation for walk or run, but they both rely on the movement speed of the player, which could be a parameter.įor our game, let’s add two new parameters: Numbers are interesting for special use cases like an horizontal or vertical speed. Trigger - a flag which stays enabled until it is used.Later, we will use these in the conditions of our transitions. Leave it enabled.Ī parameter is a value or a trigger for our state machine. We will not use this feature in this tutorial.Īnd finally, the button “Auto live Link” on the top right is a cool Unity feature which allows you to see in real-time which state is currently played. This is a way to have multiple state machines for one object. (Contrary to the image above, it should be empty currently) These parameters are used for the conditions of the transitions. On the bottom left corner of the “Animator” view, you can find a parameters list. The gray states are the normal ones, holding zero or one animation. With this state machine, any state can transition to a “Jump” state. However, if you add a few more states, you will need to create a lot of transitions to “Jump” from every state. Great, we are now able to “Jump” from the “Walk” and “Run” states. It’s not ideal, is it? We should be able to “Jump” when we “Walk” too! If you never “Run”, you will never “Jump”. It means that the “Jump” animation won’t be played unless your object is in the “Run” state before. In order to “Jump”, you have to “Walk” first, then “Run” and FINALLY “Jump”. In our “Boss” state machine, this state is, at the same time, the “Idle”, the “Hit” and the “Attack” states. ![]() It represents (as its name says so well) any state at a given time. It’s a good way to simplify a state machine. The green state, called “Any State”, is a special case. That means that when the game is started, the “Boss” object will automatically play the “Idle” animation (indefinitely if “Loop Time” is enabled in the animation “Inspector” - as it should be for this tutorial). In this case, the “Idle” state is the default one (if it’s not, right click and “Set As Default”). The orange state is the default one: the initial state when the game is launched. ![]() ![]() For now, let’s look at the three different types of states. We will focus a bit more on transitions in a moment. In order to animate the object with the “Hit” animation, we have to be in the “Idle” state first. In this image, we have created a link between two states. Each state can be an animation, and you can define transitions between them.Ī transition tells to Unity when and why it should move from a state to another. Remember when you used the “Create New Clip” button of the “Animation” view ? Unity was in fact adding a state in the controller of the object, linked to the animation file you had created.Ĭlick on each state of the animator and rename them to remove the “Boss_” prefix:Īn “Animator Controller” is a state machine. You can see that we have some states (the rectangles) created automatically with our clips, plus a special one called “Any State”. You can double click on the controller file (“Animations/Boss”) to open the controller, or you can find it in the “Window” menu: Inside an animatorĪs it was not confusing enough, we need to open the window called “Animator” (and not “Animation” this time). Yet, it doesn’t matter here because we have a very simple object with no gravity. ![]() The “Apply Root Motion” should probably be disabled when using the animations the way we do in this tutorial. Options: the “Animator” component has some other options. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |