Develop State Machines & Behavior Trees with ease and introduce them into your scenes with just one click.
Develop State Machines & Behavior Trees with ease and introduce them into your scenes with just one click.
- Add the
CogniteNode
node to your scene, its function is to allow StateMachines to be built in this scene.- Create or add a
CogniteAssemble
and start creating your graphs.
To generate the MachineState in your scene, go to the CogniteNode node and click CLICK TO ASSEMBLY
in the inspector.
If there is another node created in this way in the scene, this node will be automatically deleted.
Remember to save your resources and codes.
Currently, there are 4 types of nodes.
Each node has an important function.
State: This node is the starting point. In addition to containing a state, you can add another CogniteAssemble
, this new StateMachine will only be activated if the parent StateMachine is in the state in which this node holds the child StateMachine.
Event: Its only function is to activate this path if it receives the named signal. Therefore, there can only be 1 of this node per path, as the path will be triggered as soon as it receives the signal.
Condition: This node will observe a Boolean variable and will always maintain a path activated, if there is no Node Event
in the path, this logic will be processed every frame, you can use several nodes aligned or in parallel with no usage limit.
Change State: Its use is simple, change to a new state.
The path must always start in a State
, always end in a Change State
, at most 1 Event
node per path and the Condition
node there is no restriction.
You can acquire Cognite in your project in two ways
addons folder
. (recommended)cognite folder
to your addons folder
(if it doesn't exist, create it)Let's try out what logic would be like for an NPC soldier, first let's deduce what he will do and how he will do it:
Now let's see what this logic would look like using Cognite.
The first path starts in REST, it will observe 2 conditions in series, this means that it will only change state if the condition is accepted, in this case, the conditions are that the hunger
and bathroom
variables are false.
In REST to a second branch, there is already a detected enemy signal.
The first branch of PATROL is the same as that of REST, changing to the COMBAT state if a detected enemy is issued.
The next two branches of PATROL will change to the same state, but with different conditions and in parallel, this means that if one of the two conditions is accepted, the state will be changed.
Lastly we have the COMBAT state, it just waits for the signal of an undetected enemy to return to the PATROL state.
This node will test a float variable, if it has a value above that specified in "bigger" or "smaller", the respective paths will be activated.
The graph editor will now be accessed from the main screen, the operation will remain the same.
It is now possible to add Resource of type CogniteBehavior to the ROOT node so that it is activated when the respective state is activated. To correctly use a CogniteBehavior, extend a script and save it in a file, then drag the file to one of the states created in ROOT, the code will be called when the state is activated.