menu_bookDocumentation
SkinnedModelRenderer Animation Parameters: Set, SetIk, SetLookDirection, Pre-Spawn Caching, and ClearParameters
SkinnedModelRenderer Animation Parameters: Set, SetIk, SetLookDirection, and Pre-Spawn Caching
SkinnedModelRenderer stores animation parameters in a dictionary and applies them to the SceneModel when it's created. This means you can set parameters before the model is spawned.Setting Parameters
CSHARP
var renderer = GetComponent<SkinnedModelRenderer>();
// Set animation graph parameters
renderer.Set( "speed", 200f );
renderer.Set( "b_grounded", true );
renderer.Set( "move_style", 1 );
renderer.Set( "aim_direction", aimVector );
renderer.Set( "aim_rotation", aimRotation );
// Read parameters back
float speed = renderer.GetFloat( "speed" );
bool grounded = renderer.GetBool( "b_grounded" );
int style = renderer.GetInt( "move_style" );Look Direction Helper
Converts a world-space direction to model-local space before setting:
CSHARP
// Set a look direction parameter (world → local conversion)
renderer.SetLookDirection( "aim_eyes", eyeDirectionWorld );
// With weight
renderer.SetLookDirection( "aim_eyes", eyeDirectionWorld, weight: 1.0f );
// This also sets "aim_eyes_weight" = weightIK Helpers
Sets three parameters at once for IK targets:
CSHARP
// Sets ik.hand_r.enabled, ik.hand_r.position, ik.hand_r.rotation
renderer.SetIk( "hand_r", targetTransform );
// Disable IK
renderer.ClearIk( "hand_r" );The transform is automatically converted from world space to model-local space.
Pre-Spawn Caching
Parameters set before the SceneModel is created are cached in a Dictionary<string, object>. When the model spawns, ApplyStoredAnimParameters() applies them all and runs one animation tick to ensure the first frame is correct.
Parameters Property (Inspector)
CSHARP
// Access via the Parameters property (also shown in inspector)
renderer.Parameters.Set( "speed", 200f );
renderer.Parameters.Clear( "speed" ); // reset to default value
renderer.Parameters.Clear(); // clear all parametersClearParameters
CSHARP
renderer.ClearParameters(); // removes all stored parameters and resets the SceneModel
Was this helpful?