Skip to main content

Adding Interactivity

G3Engine uses a powerful visual scripting system based on node graphs. Build complex game logic without writing code by connecting visual nodes.

Visual Scripting Fundamentals

1
Understanding Nodes
2
Nodes are the building blocks of game logic. Each node represents an action, event, or data operation.
3
Node Categories:
4
  • Event Nodes (Red) - Start execution when something happens
  • Action Nodes (Blue) - Perform operations on objects
  • Logic Nodes (Gray) - Control flow (if/else, loops)
  • Math Nodes (Yellow) - Perform calculations
  • Variable Nodes (Green) - Get or set data
  • Web3 Nodes (Purple) - Blockchain operations
  • 5
    Node Anatomy
    6
    ┌─────────────────────────┐
    │  🔀 Branch              │  ← Header (category color + icon + name)
    ├─────────────────────────┤
    │ ◼️         │         ◻️ │  ← Execution pins (white squares)
    │ Condition  │     True   │  ← Data pins (colored circles)
    │            │    False   │
    └─────────────────────────┘
       ↑ Inputs      Outputs ↑
    
    7
    Pin Types:
    8
  • White Square (exec) - Execution flow
  • Red Circle (boolean) - True/False
  • Green Circle (float) - Decimal numbers
  • Cyan Circle (int) - Whole numbers
  • Pink Circle (string) - Text
  • Yellow Circle (vector) - 3D position
  • Blue Rounded (object) - Scene object reference
  • 9
    Opening the Node Editor
    10
  • Click the Bottom Panel to expand it
  • Switch to the Node Editor tab
  • Click ➕ Add Node to open the node palette
  • Search or browse by category (Events, Actions, Logic, Math, Web3)
  • Building Your First Interactive Behavior

    1
    Example: Move Object on Key Press
    2
    Let’s make a cube move when you press the arrow keys.
    3
    Add Event Node:
    4
  • Click ➕ Add Node
  • Search for “On Key Press”
  • Click to add it to the graph
  • 5
    ┌──────────────────────┐
    │ ⌨️ On Key Press      │
    ├──────────────────────┤
    │              ◻️      │ exec-out
    │              Key ●   │ string (which key was pressed)
    └──────────────────────┘
    
    6
    Add Action Node:
    7
  • Click ➕ Add Node again
  • Search for “Move To”
  • Add it to the graph
  • 8
    ┌──────────────────────┐
    │ ➡️ Move To           │
    ├──────────────────────┤
    │ ◼️              ◻️   │ exec in/out
    │ Target ●             │ object
    │ Position ●           │ vector
    │ Speed ●              │ float
    │              Done ◻️ │ exec (when complete)
    └──────────────────────┘
    
    9
    Connect the Nodes:
    10
  • Drag from the exec-out (white square) of “On Key Press”
  • Connect to the exec-in of “Move To”
  • The connection appears as a white line
  • 11
    Set Parameters:
    12
  • Click the “Move To” node to select it
  • In the node properties:
    • Target: Select your cube from the dropdown
    • Position: Set to {x: 2, y: 0.5, z: 0}
    • Speed: Set to 1.0
  • 13
    Now when you press a key, the cube moves to the target position!

    Common Event Nodes

    Event Begin Play

    Fires once when the game starts.
    ┌──────────────────────┐
    │ ⚡ Event Begin Play  │
    ├──────────────────────┤
    │              ◻️      │ exec-out
    └──────────────────────┘
    
    Use cases:
    • Initialize game state
    • Spawn starting objects
    • Set up the scene
    • Play background music

    Event Tick

    Fires every frame (60 times per second).
    ┌──────────────────────┐
    │ 🔄 Event Tick        │
    ├──────────────────────┤
    │              ◻️      │ exec-out
    │         Delta Time ● │ float (time since last frame)
    └──────────────────────┘
    
    Use cases:
    • Continuous movement
    • Rotation animations
    • Check conditions every frame
    • Update UI
    Use Event Tick sparingly! Too much logic in Tick can slow down your game. Prefer event-driven logic when possible.

    On Key Press

    Fires when a keyboard key is pressed.
    ┌──────────────────────┐
    │ ⌨️ On Key Press      │
    ├──────────────────────┤
    │              ◻️      │ exec-out
    │              Key ●   │ string (e.g., "ArrowUp")
    └──────────────────────┘
    
    Common key names:
    • "ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"
    • "w", "a", "s", "d"
    • "Space"
    • " Enter"

    On Click

    Fires when an object is clicked.
    ┌──────────────────────┐
    │ 👆 On Click          │
    ├──────────────────────┤
    │              ◻️      │ exec-out
    │         Position ●   │ vector (click position)
    └──────────────────────┘
    
    Use cases:
    • Clickable buttons
    • Selecting objects
    • Interactive objects
    • Point-and-click navigation

    On Collision

    Fires when two objects collide.
    ┌──────────────────────┐
    │ 💥 On Collision      │
    ├──────────────────────┤
    │              ◻️      │ exec-out
    │     Other Object ●   │ object (what we hit)
    └──────────────────────┘
    
    Use cases:
    • Collecting items
    • Taking damage
    • Triggering events
    • Bounce/physics reactions

    Common Action Nodes

    Move To

    Move an object to a position over time.
    ┌──────────────────────┐
    │ ➡️ Move To           │
    ├──────────────────────┤
    │ ◼️              ◻️   │ exec
    │ Target ●             │
    │ Position ●           │
    │ Speed ●              │
    │              Done ◻️ │
    └──────────────────────┘
    
    Parameters:
    • Target: The object to move
    • Position: Destination
    • Speed: Movement speed (units per second)
    Example:
    {
      "target": "Player",
      "position": { "x": 5, "y": 0.5, "z": 0 },
      "speed": 2.0
    }
    

    Rotate

    Rotate an object by degrees.
    ┌──────────────────────┐
    │ 🔄 Rotate            │
    ├──────────────────────┤
    │ ◼️              ◻️   │
    │ Target ●             │
    │ Degrees ●            │
    └──────────────────────┘
    
    Use case: Spinning collectibles, rotating platforms, character turning

    Spawn Object

    Create a new object in the scene.
    ┌──────────────────────┐
    │ ✨ Spawn Object      │
    ├──────────────────────┤
    │ ◼️              ◻️   │
    │ Type ●               │
    │ Position ●           │
    │            Object ●  │ (the spawned object)
    └──────────────────────┘
    
    Use cases:
    • Spawn enemies
    • Create projectiles
    • Drop items
    • Particle effects

    Destroy

    Remove an object from the scene.
    ┌──────────────────────┐
    │ 💀 Destroy           │
    ├──────────────────────┤
    │ ◼️              ◻️   │
    │ Target ●             │
    └──────────────────────┘
    
    Use cases:
    • Remove collected items
    • Destroy defeated enemies
    • Clear temporary objects

    Set Visible

    Show or hide an object.
    ┌──────────────────────┐
    │ 👁️ Set Visible       │
    ├──────────────────────┤
    │ ◼️              ◻️   │
    │ Target ●             │
    │ Visible ●            │ boolean
    └──────────────────────┘
    
    Use cases:
    • Hidden doors/passages
    • Collectible indicators
    • UI elements
    • Secret areas

    Play Sound

    Play an audio clip.
    ┌──────────────────────┐
    │ 🔊 Play Sound        │
    ├──────────────────────┤
    │ ◼️              ◻️   │
    │ Sound ●              │ string (sound name)
    │ Volume ●             │ float (0.0-1.0)
    └──────────────────────┘
    

    Logic and Flow Control

    Branch (If/Else)

    Conditional execution based on a boolean.
    ┌──────────────────────┐
    │ 🔀 Branch            │
    ├──────────────────────┤
    │ ◼️              ◻️   │ True
    │ Condition ●          │
    │              ◻️      │ False
    └──────────────────────┘
    
    Example: Only move if player has key
    1. Add “Branch” node
    2. Connect condition to “Has Key” variable
    3. Connect True output to “Move To” (open door)
    4. Connect False output to “Print String” (“You need a key!”)

    Sequence

    Execute multiple actions in order.
    ┌──────────────────────┐
    │ 📋 Sequence          │
    ├──────────────────────┤
    │ ◼️              ◻️   │ Then 0
    │              ◻️      │ Then 1
    │              ◻️      │ Then 2
    └──────────────────────┘
    
    Use case: Trigger multiple things from one event:
    1. Play sound
    2. Spawn particle effect
    3. Award points

    Delay

    Wait for a duration before continuing.
    ┌──────────────────────┐
    │ ⏱️ Delay             │
    ├──────────────────────┤
    │ ◼️              ◻️   │ Completed
    │ Seconds ●            │ float
    └──────────────────────┘
    
    Example: Timed door
    1. On trigger: Open door
    2. Delay 5 seconds
    3. Close door

    For Loop

    Repeat an action N times.
    ┌──────────────────────┐
    │ 🔁 For Loop          │
    ├──────────────────────┤
    │ ◼️              ◻️   │ Loop Body
    │ Count ●              │
    │            Index ●   │ (current iteration 0, 1, 2...)
    │         Completed ◻️ │
    └──────────────────────┘
    
    Example: Spawn 10 enemies
    1. For Loop with Count = 10
    2. Loop Body → Spawn Enemy
    3. Use Index to offset position

    Math and Variables

    Get Position

    Read an object’s current position.
    ┌──────────────────────┐
    │ 📍 Get Position      │
    ├──────────────────────┤
    │ Target ●             │
    │         Position ●   │ vector
    └──────────────────────┘
    

    Add

    Add two numbers.
    ┌──────────────────────┐
    │ ➕ Add               │
    ├──────────────────────┤
    │ A ●                  │
    │ B ●                  │
    │          Result ●    │
    └──────────────────────┘
    

    Compare

    Compare two values.
    ┌──────────────────────┐
    │ ⚖️ Compare           │
    ├──────────────────────┤
    │ A ●                  │
    │ B ●                  │
    │         A > B ●      │ boolean
    │         A = B ●      │ boolean
    │         A < B ●      │ boolean
    └──────────────────────┘
    
    Example: Check if score > 100
    1. Compare: A = score variable, B = 100
    2. Use A > B output in a Branch
    3. If true: Show victory screen

    Random Float

    Generate a random number.
    ┌──────────────────────┐
    │ 🎲 Random Float      │
    ├──────────────────────┤
    │ Min ●                │
    │ Max ●                │
    │          Value ●     │
    └──────────────────────┘
    
    Use case: Random spawn positions, random enemy behavior, procedural generation

    Complex Example: Collectible System

    1
    Goal
    2
    Create collectible coins that:
    3
  • Spin continuously
  • Play a sound when collected
  • Award 10 points
  • Disappear when collected
  • 4
    Setup
    5
  • Add a Sphere to the scene (this is your coin)
  • Name it “Collectible_Coin”
  • Set material to gold color (#ffd700)
  • Add emissive glow for visibility
  • 6
    Add Continuous Rotation
    7
    Nodes:
    8
  • Event Tick
  • Rotate
  • 9
    Connections:
    10
  • Event Tick (exec-out) → Rotate (exec-in)
  • Set Rotate target to “Collectible_Coin”
  • Set Degrees to 2 (rotates 2° per frame = smooth spin)
  • 11
    Add Collection Logic
    12
    Nodes:
    13
  • On Collision (attached to coin)
  • Branch
  • Sequence
  • Play Sound
  • Add (math node)
  • Set Variable (for score)
  • Destroy
  • 14
    Connections:
    15
  • On Collision (exec-out) → Branch (exec-in)
  • Branch condition: Check if Other Object = Player
  • Branch True → Sequence
  • Sequence Then 0 → Play Sound (“coin_collect”)
  • Sequence Then 1 → Add (A = current score, B = 10)
  • Add Result → Set Variable (score)
  • Sequence Then 2 → Destroy (target = Collectible_Coin)
  • 16
    The Complete Graph
    17
    [Event Tick] ──→ [Rotate (Coin, 2°)]
    
    [On Collision]
    
       └──→ [Branch (Other = Player?)]
    
              True ──→ [Sequence]
                         ├─ Then 0 ──→ [Play Sound]
                         ├─ Then 1 ──→ [Add] ──→ [Set Score]
                         └─ Then 2 ──→ [Destroy Coin]
    

    Tips for Visual Scripting

    Keep It Organized

    Arrange nodes left-to-right (events → logic → actions). Use the minimap to navigate large graphs.

    Color Coding

    Node headers are colored by category. Use this to quickly identify node types.

    Test Incrementally

    Test each node connection immediately. Don’t build large graphs without testing.

    Use Sequence

    When one event should trigger multiple actions, use Sequence instead of multiple connections.

    Debugging Visual Scripts

    Check that:
    • Your Event node is present (Begin Play, Tick, Key Press, etc.)
    • Execution connections (white lines) are complete
    • Target objects are correctly assigned
    • Objects are visible in the scene
    Pin types must match:
    • Exec (white square) only connects to exec
    • Data pins connect to matching types (green to green, etc.)
    • Some conversions are automatic (int to float)
    • Check Delta Time usage in Tick events
    • Adjust Speed parameters
    • Use Delay nodes to pace actions
    • Lower Rotate degrees for slower spinning
    Use the search bar in the node palette. Node names are descriptive (“Move To”, “Play Sound”, etc.)

    Advanced Patterns

    State Machine

    Use variables to track game state:
    State: "menu" → "playing" → "game_over"
    
    On Begin Play:
      Set State = "menu"
      
    On Key Press (Space):
      Branch (State = "menu")
        True → Set State = "playing"
               Start Game
    

    Timer System

    [Event Tick]
    
       └→ [Add (Time += Delta)]
    
             └→ [Compare (Time > 60)]
    
                   True → [Game Over]
    

    Health System

    [On Collision (with Enemy)]
    
       └→ [Add (Health -= 10)]
    
             └→ [Compare (Health <= 0)]
    
                   True → [Player Death]
                   False → [Play Hurt Sound]
    

    Next Steps

    Build docs developers (and LLMs) love