Develop State Machines & Behavior Trees with ease and introduce them into your scenes with just one click.
Update 1.1
Update 1.2
Update 2.0
Update 2.1
- Add the
CogniteNode
node to your scene, its function is to allow StateMachines to be built in this scene.
- Create or add a
CogniteAssemble
, aCogniteSource
and start creating your graphs.
With this node you can access the state machine and interact with its properties.
Resource where graph data is saved, you can save it to reuse in other CogniteNodes.
Resource for configuring CogniteAssemble, you can reuse it in different CogniteAssemble to create different behaviors using the same data that your scene can access, avoiding the need to edit other scene 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
- Download the latest version and extract it into the
addons folder
. (recommended) - Download directly to your godot 4.2 via Godot Asset Library
- Clone this repository and add the
cognite folder
to youraddons 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:
- He must patrol the region in search of any enemies.
- Regardless of what you are doing, if an enemy is detected, it must enter COMBAT mode.
- If he hears no enemy sightings, he will return to patrol.
- Periodically, he may stop the patrol to eat or go to the bathroom.
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.
Now, the behavior will be built in real time, using Callable
instead of conversion to GDScript.
Additionally, there is no longer CogniteBehavior
, there is now a more efficient way to create state blocks.
It is enough that the direct child node of CogniteNode
has exactly the name of a state.
The start()
function will be called when the state is started, the _process(delta)
and _physics_process(delta)
functions will ONLY be available when the state is activated.
-
You can now choose an initial state via the CogniteNode Inspector.
-
Added right-click feature to create a GraphNode.
-
Press DELETE to remove the selected nodes (caution! irreversible action).