Scripting (ModuCPP, C++, C, and C#)
Modularity supports four scripting layers:
| Layer | Primary use | Main docs |
|---|---|---|
ModuCPP | High-level gameplay, UI, editor, and runtime scripting | ModuCPP Overview |
Native C++ | Lower-level engine-adjacent scripts and direct ScriptContext work | ModuCPP API: ScriptContext |
Native C | Small bridge-style scripts through ScriptRuntimeCAPI.h | See include/ScriptRuntimeCAPI.h and the C sections in older revisions of this page |
Managed C# | Mono-hosted scripts using Scripts/Managed/ModuCPP.cs | Mono 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:
Quick Notes
add ModuCPP;gives you the core language helpers. It does not automatically importModuEngine,ModuInput,RMeshBuilder, orModuCPP.Experimental.ModuNodeis the preferred high-level script base for new gameplay scripts.ModuBehaviouris 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()orinspector { ... }. - 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 useScriptContext,MODU_SCRIPT(ctx), and the helper headers underinclude/. - Native
Cscripts useinclude/ScriptRuntimeCAPI.handModu_*exports. - Managed
C#scripts useScripts/Managed/ModuCPP.cs,ModuCPP.Context, andModuCPP.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
TickUpdateand 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.