Databrain Documentation
databrain.ccDiscord
  • Welcome
  • Installation / Update
  • Interface
  • DataObject Property Drawer
    • No GUI Implemented - FIX
  • Getting started
  • Guides
    • Add data objects
    • Add data objects at runtime
    • Get initial data
    • Get/Set runtime data
    • Serialize DataObjects
    • Runtime Save & Load
    • Use custom serializer
    • Import
    • Search
    • Custom GUI
    • Custom GUI with Odin Inspector
    • Hierarchy Template
  • Separate DataObjects
  • Using Version Control
  • Attributes
    • DataObject attributes
    • Field attributes
  • API
    • DataLibrary
    • DataObject
  • FAQ
    • Databrain - FAQ
  • Add-ons
    • Events
    • Blackboard
    • Logic
      • Interface
      • Create Graph
      • Execute graph
      • Control flow execution in groups
      • Custom Nodes
        • Asynchronous execution
        • Node Attributes
      • Scene Components
      • Graph Events
      • Finite State Machine
        • Create custom Actions
        • Examples
        • State Machine Nodes
    • Stats
      • Achievements
      • Modifiers
      • Values
      • Progressions
      • Components
      • Nodes
    • Progress
      • Progress Settings
      • Progress Graph
      • Progress Resources
      • Runtime UI Setup
      • API
        • ProgressController
    • Techtree (LEGACY)
      • Techtree Manager
      • Techtree
      • TechtreeResource
      • Techtree UIBuilder
        • Custom Techtree Node Button
        • Tooltip
      • API
    • Localization
      • Localization Manager
      • Localization
      • Examples
      • Components
      • Import
      • API
    • Inventory
      • Getting started
      • Demo
      • Data setup
        • Inventories
        • Slot IDs
        • Items
          • Blueprints
          • Item rarities
        • Money
        • Loot tables
        • Events
      • Runtime UI
        • Setup
    • Dialogue
      • Getting Started
        • Demo
      • Dialogue runtime setup
      • Actors
        • Emotions
      • Localization
      • Audio
      • Animation
      • Variables
      • Custom theme
      • Import
      • Nodes
      • API
        • DialogueController
        • IDialogueUIControl
  • Changelog
    • Databrain - Changelog
      • 1.4.0
      • 1.3.2
      • 1.3.1
      • 1.3.0
      • 1.2.0
      • 1.1.0
      • 1.0.10
      • 1.0.9
      • 1.0.8
      • 1.0.7
      • <= 1.0.6
Powered by GitBook
On this page
  1. Add-ons
  2. Logic
  3. Finite State Machine

Create custom Actions

To create a custom FSM action, simply right click in the project view and select: Create / Databrain / Logic / New FSM Action node

A new node class will be created which looks like this:

using System;
using Databrain.Logic.Attributes;
using UnityEngine;

namespace Databrain.Logic.StateMachine
{
    [NodeTitle("MyStateAction")]
    [NodeCategory("StateMachine/States")]
    [NodeOutputs(new string[] {"Next"})]
    [NodeDescription("This is a node description")]
    [NodeSize(260, 100)]
    [NodeColor("#C2FAFF", new string[]{"#74AFE0","","",""})]
    [NodeIcon("fsmAction.png", "LogicResPath.cs")]
    [NodeInputConnectionType(new Type[] {typeof(Actions)})]
    public class MyStateAction : StateMachineActionNode
    {

        public override void OnEnter()
        {
            // On Enter
        }

        public override void OnExit()
        {
            // On Exit
        }

        public override void OnUpdate()
        {
            // On update is called by the state machine controller node on every tick
        }   
    }
}

As you can see, the class has some node attributes like: NodeTitle, NodeDescription and NodeColor. To know more about NodeAttributes please read: Node Attributes

The body of the class contains three methods: OnEnter, OnExit and OnUpdate. This is where you can add your code.

  • OnEnter: Is called when entering the state

  • OnExit: Is called when exiting the state

  • OnUpdate: Is called on every tick by the FSM Controller

PreviousFinite State MachineNextExamples

Last updated 1 year ago