Git Product home page Git Product logo

cognite's Introduction

Generic badge Generic badge

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

How to use

  • Add the CogniteNode node to your scene, its function is to allow StateMachines to be built in this scene.
  • Create or add a CogniteAssemble, a CogniteSource and start creating your graphs.


CogniteNode

With this node you can access the state machine and interact with its properties.

CogniteAssemble

Resource where graph data is saved, you can save it to reuse in other CogniteNodes.

CogniteSource

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 general rule for using nodes:

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.


install guide

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 your addons folder (if it doesn't exist, create it)

Examples

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.

Update 1.1

Node Range added

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.

Update 1.2

Now on the Main Screen

The graph editor will now be accessed from the main screen, the operation will remain the same.

CogniteBehavior

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.

Update 2.0

No code generation, everything virtual

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.

cognite's People

Contributors

matheus-s-arruda avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

cognite's Issues

Some suggestions

Hey man, great plugin, I found it very interesting, I'm doing some tests with it, but for now I'm not using it in any project.

I would like to make some suggestions.

  • Having a step-by-step text on how to use the plugin, something very simple and direct.

  • The first step in using the plugin could be directly in the "Cognite editor" and have some buttons to create nodes and resources.

  • Its usability could be more fluid if the editor was moved to the top bar of godot, being more centralized and using the entire editor screen. The G-Kanban plugin does this for example.

image

Note: As there is no contribution guide yet, I ended up putting together some suggestions. I hope I can contribute to the plugin in the future ๐Ÿ˜Š

Cannot trigger event from multiple states

Really love the plugin so far and I'd love to use it for enemy ai, but it seems to be breaking down on me.

I'm trying to extend the example graph in the readme with a Hunt state, pictured here:
image

I have a super simple script that calls cognite_node.enemy_detected.emit() along with enemy_lost and chill respectively. Everything works as expected, except for the transition from HUNT to COMBAT. Triggering enemy_detected while in the HUNT state does nothing.

Maybe I'm doing something wrong, would appreciate any insight.

I'm using Godot 4.2 stable and Cognite 2.0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.