Scripting (ModuCPP, C++, C, and C#)

Modularity supports four scripting layers:

LayerPrimary useMain docs
ModuCPPHigh-level gameplay, UI, editor, and runtime scriptingModuCPP Overview
Native C++Lower-level engine-adjacent scripts and direct ScriptContext workModuCPP API: ScriptContext
Native CSmall bridge-style scripts through ScriptRuntimeCAPI.hSee include/ScriptRuntimeCAPI.h and the C sections in older revisions of this page
Managed C#Mono-hosted scripts using Scripts/Managed/ModuCPP.csMono Embedding Setup
ModuCPP is the recommended scripting layer for new scripts. It is transpiled to native C++, so it keeps native runtime behavior while providing higher-level syntax, generated inspectors, and module-based imports.

ModuCPP Documentation

Start here when you are writing or maintaining .moducpp scripts:

Recommended reading order:

  1. Getting Started
  2. Script Structure
  3. Imports and Modules
  4. Fields and Inspector
  5. Methods and Lifecycle

Quick Notes

  • add ModuCPP; gives you the core language helpers. It does not automatically import ModuEngine, ModuInput, RMeshBuilder, or ModuCPP.Experimental.
  • ModuNode is the preferred high-level script base for new gameplay scripts.
  • ModuBehaviour is still supported for older scripts and native-style ports.
  • Public ModuCPP fields are persisted and exposed in the inspector unless you override them with Script_OnInspector() or inspector { ... }.
  • Private ModuCPP fields are runtime-only state.

Native and Managed Bridges

These areas are still supported, but they are separate from the new module-split ModuCPP manual/reference set:

  • Native C++ scripts use ScriptContext, MODU_SCRIPT(ctx), and the helper headers under include/.
  • Native C scripts use include/ScriptRuntimeCAPI.h and Modu_* exports.
  • Managed C# scripts use Scripts/Managed/ModuCPP.cs, ModuCPP.Context, and ModuCPP.ImGui.

For current managed runtime layout, ABI versioning, and build notes, use:

Examples in This Repo

The V6.9 handbook includes complete, copy-ready scripts with required components, scene setup, inspector configuration, and the full source:

  • FPS Display - the smallest working example: update a UI text object from TickUpdate and optionally cap the frame rate.
  • Top-Down 2D Movement - normalized movement, Rigidbody2D acceleration and drag, directional sprite clips, sprinting, and footsteps.
  • Standalone 3D Movement - camera-relative movement, action input, grounding, facing, and jumping through the Rigidbody3D facade.
  • Main Menu Controller - UI object references, a moving cursor, custom inspector tabs, navigation sounds, and per-item actions.
  • Dialogue System - localized typewriter dialogue, text effects, mouth states, audio, animation hooks, and cross-script settings.
  • Interactable Object - E-key interaction, range checks, selection states, object toggles, and dialogue handoff.
  • DialoguePortShared.h - the shared sample types, serialization, and editor helpers required by the dialogue examples.

Start with FPS Display if this is your first script. Dialogue System and Interactable Object are intentionally larger examples that show how multiple scripts and a shared header cooperate.