Step 3: Character - Action States

Goal

  • Undertand what Action State is

  • Find Tag Container

  • Understand how Action State are connected to Input Tags


Find SwordMoveset

Under MyFirstCharacter, you can find SwordMoveset Object.

Click onto Attack1.

What matters in this step is the Action State Script.

An Action State is the minimal state that describes a character’s action.

Action States include locomotion actions like moving, jumping, dashing, or combat actions like swinging a sword or firing a gun. It is the basic unit that adds up to the entirety of our action system in PAT. Action State by itself has very limited functionality, it serves as a that shows which state a character is in (what it is doing), and what it can do from the current state.

For more details, you can find in Action State.

Most real functionalities are fulfilled by State Modifiers that are add on to Action States, and we will cover those later.

So how does an Action State know when it should be triggered? What allows the penguin to attack after a left click?


Input Unit

If you recall what we mentioned at the end of Step 2: Tutorial Scene, the Player Component handles your inputs. Each input unit bounds an action reference from the Input Action System to an Input Tag.

Player Component from last step

For example, if you input the Attack button (left clicking your mouse / west button on controller), the Player will send a Light Attack Tag to the Character, and Character will find if it matches the Action State's Input Tag.


Tag Container

For you to check what tags were sent to a character, we have a component called Tag Container generated by Character component. In this tutorial, it is on MyFirstCharacter.

Note that it is only added to the object at runtime, so you have to start the game first to find it in the inspector.

Tag Container is a very useful tool for debugging your character, especially when the character doesn't behave as you expected. You can check whether the player input is correctly handled, or which State Tags are added to the character at this moment.

How the Tag Container looks like if you left click your mouse

Input Tag

On each Update, all Action States compare their Input Tags with current tags in Tag Container. If they found the matching Input Tag, the Action State will try to be triggered. This is how the penguin attacks -- It receives an Input Tag from the Player.

Input Tag - Light Attack

Now let's try do the same thing for another Action State.

Last updated