AgentSkillsCN

unity-animator

创建并管理动画控制器及其参数。

SKILL.md
--- frontmatter
name: unity-animator
description: "Create and manage Animator Controllers and parameters."

Unity Animator Skills

Control Unity's animation system - create controllers, manage parameters, and control playback.

Skills Overview

SkillDescription
animator_create_controllerCreate new Animator Controller
animator_add_parameterAdd parameter to controller
animator_get_parametersList all parameters
animator_set_parameterSet parameter value at runtime
animator_playPlay animation state
animator_get_infoGet Animator component info
animator_assign_controllerAssign controller to GameObject
animator_list_statesList states in controller

Parameter Types

TypeDescriptionExample Use
floatDecimal valueSpeed, blend weights
intInteger valueState index
boolTrue/falseIsGrounded, IsRunning
triggerOne-shot signalJump, Attack

Skills

animator_create_controller

Create a new Animator Controller.

ParameterTypeRequiredDefaultDescription
namestringYes-Controller name
folderstringNo"Assets"Save folder

Returns: {success, name, path}

animator_add_parameter

Add a parameter to a controller.

ParameterTypeRequiredDefaultDescription
controllerPathstringYes-Controller asset path
paramNamestringYes-Parameter name
paramTypestringYes-float/int/bool/trigger
defaultValueanyNo0/falseInitial value

animator_get_parameters

Get all parameters from a controller.

ParameterTypeRequiredDescription
controllerPathstringYesController asset path

Returns: {success, parameters: [{name, type, defaultFloat/defaultBool/...}]}

animator_set_parameter

Set a parameter value at runtime.

ParameterTypeRequiredDescription
namestringYesGameObject name
paramNamestringYesParameter name
paramTypestringYesfloat/int/bool/trigger
floatValuefloatNo*Float value
intValueintNo*Integer value
boolValueboolNo*Boolean value

*Use the appropriate value for paramType (trigger doesn't need a value)

animator_play

Play a specific animation state.

ParameterTypeRequiredDefaultDescription
namestringYes-GameObject name
stateNamestringYes-Animation state name
layerintNo0Animator layer
normalizedTimefloatNo0Start time (0-1)

animator_get_info

Get Animator component information.

ParameterTypeRequiredDescription
namestringYesGameObject name

Returns: {success, hasController, controllerName, parameters, currentState}

animator_assign_controller

Assign a controller to a GameObject.

ParameterTypeRequiredDescription
namestringYesGameObject name
controllerPathstringYesController asset path

animator_list_states

List all states in a controller layer.

ParameterTypeRequiredDefaultDescription
controllerPathstringYes-Controller asset path
layerintNo0Layer index

Returns: {success, states: [{name, tag, speed}]}


Example: Complete Animation Setup

python
import unity_skills

# 1. Create controller
unity_skills.call_skill("animator_create_controller",
    name="PlayerController",
    folder="Assets/Animations"
)

# 2. Add parameters
unity_skills.call_skill("animator_add_parameter",
    controllerPath="Assets/Animations/PlayerController.controller",
    paramName="Speed", paramType="float", defaultValue=0
)
unity_skills.call_skill("animator_add_parameter",
    controllerPath="Assets/Animations/PlayerController.controller",
    paramName="IsGrounded", paramType="bool", defaultValue=True
)
unity_skills.call_skill("animator_add_parameter",
    controllerPath="Assets/Animations/PlayerController.controller",
    paramName="Jump", paramType="trigger"
)

# 3. Assign to character
unity_skills.call_skill("animator_assign_controller",
    name="Player",
    controllerPath="Assets/Animations/PlayerController.controller"
)

# 4. Control at runtime
unity_skills.call_skill("animator_set_parameter",
    name="Player", paramName="Speed", paramType="float", floatValue=5.0
)

# Trigger jump
unity_skills.call_skill("animator_set_parameter",
    name="Player", paramName="Jump", paramType="trigger"
)

# Play specific state
unity_skills.call_skill("animator_play", name="Player", stateName="Idle")

Best Practices

  1. Create controller before adding parameters
  2. Use meaningful parameter names
  3. Triggers reset automatically after firing
  4. Set parameters before playing states
  5. Use layers for independent animations (body + face)
  6. States must exist in controller before playing