State Manager Component {{ currentPage ? currentPage.title : "" }}

OVERVIEW:

The system core Component is the State manager component. The State manager component has very basic functionality in it that you can can use. the most important things to keep in mind for it is that you must have classes

that inherit from “BP_BaseState” to be able to use it. we prefer having states in the controller. as states are usually broader in meaning. an example would be if your attacking. “attacking” is very broad, you can do different types of attacks based on lots of different variables. and most of that is input based, that’s why the controller was chosen.

FUNCTIONALITY:

The state manager components keep a record of all the states that can be fired at any given point. with that in mind, there will always remain in an array all the time. and only ONE can be active at any given point, so do your programming with that in mind.

There are 2 main functions in it:

  • Try Perform State Of Class:

this function will fire given that you provide it with the appropriate class, with this function there is an option with condition check, this will be explained in the “Base State Object” section.

  • Perform State of Class:

just like the above function, the only difference is that it doesnt require a condition to fire:

————————————————————————————————————————————————————-

Base State Object:

states need to have a setup upon creating the class, you can create a class by clicking the following menu:

after clicking it, you will have to choose one of the following states:

you can already see there are different classes for states, one of the player and another for the AI. and each has a more specific functionality ADDED to it other than what is mentioned below. you can use it on anything you want, AI, player character, Actors. just keep in mind the functionality each of those classes can provide you.

variables:

Additionally, Each State Can be configured differently. you MUST assign a gameplay tag to it to help identify it later if you want to. in additon to that, if you want it to have a time controller, you can specify the “Time Controlled State” Boolean and modify the floats under it if you want something in particular to happen if the timer reaches its limit.

see from the “BP_BaseState” that all states inherit from. The most important functionality in it relies on those specific functions shown below:

  • Construct State:

This function gets called when you construct the state for the very first time, an example would be when you equip a new weapon. with the sample provided, every weapon you attempt to equip ( wheither its on begin play or on overlap ) wil have a specific “data asset” associated with it. That Data Asset has “states” that can fire when the specific weapon gets equipped. once that data asset is registered. all the states within it will be constructed, and thats when this function will fire, so any variables you think you might use in that state can be saved on construction of that state.

  • Start State:

From it’s name, it will call this function whenever the state starts. most states from the player fire from the inputs the player triggers during gameplay, you can refer more to the provided “TCF_PlayerController” to see how to trigger it.

  • Tick State:

this one is extremely important as it runs on tick, please note that this function ONLY fires if the state is ACTIVE. meaning, if you have multipile states registered, none of the tick functions will fire unless its active, and only ONE state is active at any given point.

  • End State:

This function fires when a new state gets called. for example, if you have an idle state and an attacking state. the moment attacking gets called, it will attempt to end the state that is active BEFORE the new attacking state starts.

  • Can Perform State:

this function gets called when the developer calls the “Try Perfrom Ability Of Class” from the state manager component. if you have the condition set to true, this function will get called.

All the provided Functions can be overridden from blueprints, so you can create any type of behavior if you keep the notes above in mind

{{{ content }}}