Scripting
Overview
SafiEngine uses native C++ behaviors for all gameplay logic. Behaviors are classes that extend the Behavior base class and have full access to every engine subsystem: input, physics, audio, ECS, rendering, and more.
Unlike external scripting languages, behaviors compile directly into the engine binary. This means zero overhead, full type safety, and complete access to the C++ standard library.
Behavior Lifecycle
Every behavior has two virtual methods:
Both methods receive the entity the behavior is attached to and a reference to the engine.
Engine Subsystems
Inside any behavior method you have access to every subsystem:
Workflow
- Create a
.cppfile inCore/src/behaviors/ - Define a class extending
Behavior - Export a registration function
- Add the forward declaration and call in
Behavior.cpp - Add the file to
Core/CMakeLists.txt - Rebuild the engine
See Getting Started for a step-by-step walkthrough.
Section Contents
- Getting Started - Your first script
- Input & Controls - Keyboard, mouse, action mapping
- Transform - Position, rotation, scale
- Physics - Velocity, forces, rigid bodies
- Camera - Camera control and switching
- Animation - Skeletal animation control
- Audio - Sound playback and 3D audio
- Entities - Working with other entities
- Events - Communication between behaviors
- Script Properties - Inspector-configurable parameters
- Complete Examples - Full working behaviors