That means:
- you import a model asset such as
.glb,.gltf, or.iqm - you assign it to a
ModelRenderer - if the asset contains animations, or you assign a separate animation source, Lenga can play those imported clips at runtime
Use this workflow when your model file already contains animation clips, or when your project stores imported animation in a separate model file.
If you are still getting comfortable with scene scripting, keep the core object model nearby:
What ModelRenderer Does
ModelRenderer supports:
- selecting a model asset
- selecting an optional animation source asset
- choosing which imported animation to play
- controlling
Play On Awake - controlling
Loop - controlling playback
Speed - controlling playback
Playback FPS - starting and stopping playback from PHP
If Animation Source is left empty, Lenga will try to use embedded animations from the selected Model asset.
Basic Scene Workflow
- Create or select a
GameObject. - Add a
ModelRenderercomponent. - Assign a model file to
Model. - If your animation lives in a separate file, assign it to
Animation Source. - Choose the imported animation from the
Animationdropdown. - Set
Loop,Speed, andPlayback FPS. - Press Play.
If the asset exposes animation names, the Inspector shows those names directly. If not, you can still choose the animation by numeric index.
PHP Example
use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\ModelRenderer;
final class CharacterAnimationBootstrap extends Behaviour
{
private ?ModelRenderer $modelRenderer = null;
public function start(): void
{
$this->modelRenderer = $this->gameObject->getComponent(ModelRenderer::class);
if (!$this->modelRenderer instanceof ModelRenderer) {
return;
}
$this->modelRenderer->modelPath = 'Assets/Models/Knight.glb';
$this->modelRenderer->animationIndex = 0;
$this->modelRenderer->loop = true;
$this->modelRenderer->speed = 1.0;
$this->modelRenderer->playbackFps = 30.0;
$this->modelRenderer->play();
}
}
Using A Separate Animation Source
Some pipelines store the skeleton/model and animations in separate files.
use Lenga\Engine\Core\Behaviour;
use Lenga\Engine\Core\ModelRenderer;
final class EnemyAnimationSetup extends Behaviour
{
public function start(): void
{
$renderer = $this->gameObject->getComponent(ModelRenderer::class);
if (!$renderer instanceof ModelRenderer) {
return;
}
$renderer->modelPath = 'Assets/Models/Enemy.iqm';
$renderer->animationPath = 'Assets/Models/Enemy_Run.iqm';
$renderer->animationIndex = 0;
$renderer->loop = true;
$renderer->play();
}
}
Pause and Step Behaviour
Imported 3D model animation uses scaled gameplay time.
That means:
- pausing the engine freezes model animation playback
- stepping one frame in the editor advances model animation by one authored frame step
- changing
speedchanges how quickly the animation advances through its imported frames
This keeps 3D animation aligned with the same pause/step model used elsewhere in Lenga.
Use imported playback when you need animated 3D models.
Recommended Next Steps
After you have playback working:
- create a small 3D sample scene that proves the scripting surface end to end
- standardize your model import pipeline so animation names and clip ordering stay predictable
- decide early whether a specific project wants one-file embedded animation assets or separate model/animation files
- use the Transform and GameObject API for follow cameras, sockets, spawn points, and runtime model setup