• Studio

  • Bots

  • Web API

  • Designer Resources

  • Host Resources

  • Animator

    Inherits from: Behaviour

    The Animator class is a core component in Unity for managing animations. It works with the Animator Controller to manage states and transitions in a state machine, enabling complex animation setups. This class provides a variety of methods and properties to control animations on GameObjects, essential for dynamic and interactive game environments.

    Properties

    Indicates if the Animator can be optimized for performance.

    isHuman

    boolean

    Checks if the Animator controls a humanoid model.

    Determines if the Animator's animation data contains root motion.

    Provides the scale of the humanoid Avatar in meters.

    Checks if the Animator is initialized and ready to control animations.

    Returns the GameObject's position change during the last frame.

    Provides the rotation difference of the GameObject during the last frame.

    Gives the velocity vector of the GameObject controlled by the Animator.

    Returns the angular velocity vector of the GameObject.

    Provides the position of the root of the GameObject controlled by the Animator.

    Offers the rotation of the root of the GameObject controlled by the Animator.

    Controls whether root motion in animations should be applied to the GameObject.

    Indicates if the Animator has a transform hierarchy.

    Represents the gravity weight based on current animations being played.

    Allows getting or setting the position of the body mass.

    Lets you get or set the rotation of the body mass.

    Controls feet stabilization for plant and IK feet.

    Represents the total number of layers within the Animator.

    Pertains to the count of parameters in the Animator Controller.

    A blend variable for calculating the position of each foot during a transition.

    Indicates the current weight of the pivot, as determined by foot animations.

    Offers the current position of the pivot in the avatar root, relative to world space.

    Indicates whether the character is currently matching a target via script.

    speed

    number

    Allows manipulation of the Animator's playback speed.

    Gets the target position for the MatchTarget function.

    Fetches the target rotation for the MatchTarget function.

    Refers to the root Transform of the humanoid Avatar in the animator.

    Gets the current playback time of the Animator recorder.

    Represents the start time of the first frame of the Animator recorder.

    Provides the stop time of the last frame of the Animator recorder.

    Indicates whether any playable graphs are attached to the Animator.

    Controls whether the mass center is affected by all layers or only the base layer.

    Provides the position of the bottom of the left foot relative to the root.

    Represents the position of the bottom of the right foot relative to the root.

    Controls whether warnings are logged for issues with AnimatorController setup.

    fireEvents

    boolean

    Dictates whether the Animator is allowed to emit events.

    Keeps the current Animator state and its time when the GameObject is disabled.

    Writes default values into the GameObject when the animator component is disabled.

    Methods

    Retrieves a float parameter from the Animator.

    Parameters

    name

    string

    The name of the parameter to retrieve.

    Returns

    number

    The float value of the specified parameter.

    Sets the value of a float parameter.

    Parameters

    name

    string

    Name of the parameter.

    value

    number

    The value to be set.

    Returns

    void

    This method doesn't return a value.

    Retrieves the value of a boolean parameter in the Animator.

    Parameters

    name

    string

    Name of the parameter.

    Returns

    boolean

    The current state (true or false) of the specified parameter.

    Sets the value of a boolean parameter in the Animator.

    Parameters

    name

    string

    Name of the parameter.

    value

    boolean

    The value to be set.

    Returns

    void

    This method doesn't return a value.

    Fetches the value of an integer parameter in the Animator.

    Parameters

    name

    string

    Name of the parameter.

    Returns

    number

    The current state of the specified parameter.

    Assigns an integer value to an integer parameter in the Animator.

    Parameters

    name

    string

    Name of the parameter.

    value

    number

    The value to be set.

    Returns

    void

    This method doesn't return a value.

    Activates a trigger parameter to change the animator's state.

    Parameters

    name

    string

    Name of the trigger parameter.

    Returns

    void

    This method doesn't return a value.

    Clears a trigger parameter.

    Parameters

    name

    string

    Name of the trigger parameter to reset.

    Returns

    void

    This method doesn't return a value.

    Checks if a parameter is controlled by a curve.

    Parameters

    name

    string

    The name of the parameter to check.

    Returns

    boolean

    True if the parameter is controlled by a curve, false otherwise.

    Sets a target position for the character's head to look at.

    Parameters

    lookAtPosition
    Vector3

    Position for the character to look at.

    Returns

    void

    This method doesn't return a value.

    Sets the weights for the head and body parts to look at a position.

    Parameters

    weight

    number

    The weight by which the body parts follow the lookAtPosition.

    Returns

    void

    This method doesn't return a value.

    Retrieves the name of a layer by its index.

    Parameters

    layerIndex

    number

    The index of the layer.

    Returns

    string

    The name of the layer.

    Finds the index of a layer by its name.

    Parameters

    layerName

    string

    The name of the layer.

    Returns

    number

    The index of the layer.

    Gets the weight of a layer, defining its influence on the final animation.

    Parameters

    layerIndex

    number

    The index of the layer.

    Returns

    number

    The weight of the layer.

    Sets the weight of a layer, adjusting its influence on the final animation outcome.

    Parameters

    layerIndex

    number

    The index of the layer.

    weight

    number

    The weight to set for the layer.

    Returns

    void

    This method doesn't return a value.

    Returns the count of AnimatorClipInfo instances for the current layer.

    Parameters

    layerIndex

    number

    The index of the layer.

    Returns

    number

    The count of AnimatorClipInfo instances.

    Gets the count of AnimatorClipInfo for the next layer the animator will transition to.

    Parameters

    layerIndex

    number

    The index of the layer.

    Returns

    number

    The count of AnimatorClipInfo instances for the next layer.

    Checks if the animator is in a transition between animations in the state machine.

    Parameters

    layerIndex

    number

    The index of the layer.

    Returns

    boolean

    True if the animator is in transition, false otherwise.

    Interrupts automatic target matching, allowing manual control.

    Returns

    void

    This method doesn't return a value.

    Gradually blends from the current animation to another over a fixed time.

    Parameters

    stateName

    string

    The name of the state to transition to.

    fixedTransitionDuration

    number

    The duration of the transition.

    Returns

    void

    This method doesn't return a value.

    Writes default values to the Animator, resetting runtime modifications.

    Returns

    void

    This method doesn't return a value.

    Transitions from the current state to another over a relative duration.

    Parameters

    stateName

    string

    The name of the state.

    normalizedTransitionDuration

    number

    Duration of the transition relative to animation length.

    layer

    number

    Index of the layer.

    normalizedTimeOffset

    number

    Adjusts the starting point of the transition.

    Returns

    void

    This method doesn't return a value.

    Plays an animation state at a specified time scale, unaffected by Animator speed.

    Parameters

    stateName

    string

    The name of the state to play.

    layer

    number

    The layer index.

    Returns

    void

    This method doesn't return a value.

    Plays an animation state, allowing direct control over animation playback.

    Parameters

    stateName

    string

    The name of the state.

    layer

    number

    The layer index.

    Returns

    void

    This method doesn't return a value.

    Begins animator playback mode, useful for testing Animator functionality.

    Returns

    void

    This method doesn't return a value.

    Stops animator playback mode initiated by StartPlayback.

    Returns

    void

    This method doesn't return a value.

    Starts recording the Animator in play mode for analysis or replaying sequences.

    Parameters

    frameCount

    number

    Number of frames to record.

    Returns

    void

    This method doesn't return a value.

    Stops recording started by StartRecording, controlling recording duration.

    Returns

    void

    This method doesn't return a value.

    Checks if a specific state exists within a layer of the Animator.

    Parameters

    layerIndex

    number

    The index of the layer.

    stateID

    number

    The ID of the state to check for existence.

    Returns

    boolean

    True if the state exists in the specified layer, false otherwise.

    Manually advances the Animator state machine by a specified amount of time.

    Parameters

    deltaTime

    number

    The amount of time to advance the state machine.

    Returns

    void

    This method doesn't return a value.

    Resets the Animator to its default state, removing all runtime modifications.

    Returns

    void

    This method doesn't return a value.

    Applies built-in root motion from animation clips, if present.

    Returns

    void

    This method doesn't return a value.

    Converts a string into a hash ID for efficient parameter identification.

    Parameters

    name

    string

    The string to convert into a hash ID.

    Returns

    number

    The hash ID of the string.

    PocketWorlds Icon

    © 2024 Pocket Worlds. All rights reserved.