menu_bookDocumentation
Animation - s&box Documentation
Animation
s&box supports skeletal animation for characters and objects. Animate models using imported animations, blend between states, and control playback from code.
Movie Maker
The Movie Maker tool can create skeletal animations that are usable in-game:
- Animate character poses over time
- Export as animation asset
- Use in your game's SkinnedModelRenderer
Animation System
Character animation uses the SkinnedModelRenderer component:
CSHARP
var renderer = Components.Get<SkinnedModelRenderer>();
// Play an animation
renderer.PlayAnimation( "run" );
// Blend between animations
renderer.SetAnimParameter( "speed", velocity.Length );Animation Parameters
Control animation state through parameters:
CSHARP
// Set float parameter
renderer.SetAnimParameter( "speed", 5.0f );
// Set boolean parameter
renderer.SetAnimParameter( "is_jumping", true );
// Set integer parameter
renderer.SetAnimParameter( "weapon_type", 1 );Animation Events
Receive events from animations (footsteps, sounds):
CSHARP
protected override void OnAnimEvent( string name, string parameter )
{
if ( name == "footstep" )
{
PlayFootstepSound();
}
}SceneAnimationSystem
For complex animation management, use the scene animation system:
CSHARP
// Access via Scene
var animSystem = Scene.GetSystem<SceneAnimationSystem>();Sources
Animations come from:
- Imported FBX files with skeletal animation
- Movie Maker created animations
- Procedural animation (IK, ragdolls)
Was this helpful?