Normalized time of the State. The integer part is the number of time a state has been looped. The fractional part is the % (0-1) of progress in the current loop.
Returns the value of the given float parameter. name: The name of the parameter.id: The id of the parameter.
Parameter
Type
Description
getParam = Space.Host.ExecutingObject.Animator.GetFloat("paramName")-- or paramID = Space.Host.ExecutingObject.Animator.StringToHash("paramName")getParam = Space.Host.ExecutingObject.Animator.GetFloat(paramID)
--clicking the object will toggle it's Animator's "flySpeed" float parameter between 0.0 and 5.0thisObject = Space.Host.ExecutingObjectOnClick=function()if thisObject.Animator.GetFloat("flySpeed") ==0.0then thisObject.Animator.SetFloat("flySpeed", 5.0) else thisObject.Animator.SetFloat("flySpeed", 0.0) endendthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
--clicking the object will toggle it's Animator's "flySpeed" float parameter between 0.0 and 5.0--this script uses parameter ID instead of string (StringToHash function gets the ID)thisObject = Space.Host.ExecutingObjectparamID = thisObject.Animator.StringToHash("flySpeed")OnClick=function()if thisObject.Animator.GetFloat(paramID) ==0.0then thisObject.Animator.SetFloat(paramID, 5.0) else thisObject.Animator.SetFloat(paramID, 0.0) endendthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
GetBool
bool GetBool (string name)
bool GetBool (int id)
Returns the value of the given boolean parameter. name: The name of the parameter.id: The id of the parameter.
--clicking the object will toggle it's "isFlying" bool parameter between true and falsethisObject = Space.Host.ExecutingObjectOnClick=function()if thisObject.Animator.GetBool("isFlying") ==truethen thisObject.Animator.SetBool("isFlying", false) else thisObject.Animator.SetBool("isFlying", true) endendthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
--clicking the object will toggle it's "isFlying" bool parameter between true and false--this script uses parameter ID instead of string (StringToHash function gets the ID)thisObject = Space.Host.ExecutingObjectOnClick=function() parameterID = thisObject.Animator.StringToHash("isFlying")if thisObject.Animator.GetBool(parameterID) ==truethen thisObject.Animator.SetBool(parameterID, false) else thisObject.Animator.SetBool(parameterID, true) endendthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
GetInteger
int GetInteger (string name) int GetInteger (int id)
Returns the value of the given integer parameter. name: The name of the parameter.id: The id of the parameter.
--clicking the object will toggle it's Animator's "jumpHeight" int parameter between 0 and 5thisObject = Space.Host.ExecutingObjectOnClick=function()if thisObject.Animator.GetInteger("jumpHeight") ==0then thisObject.Animator.SetInteger("jumpHeight", 1) else thisObject.Animator.SetInteger("jumpHeight", 0) endendthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
--clicking the object will toggle it's Animator's "jumpHeight" int parameter between 0 and 5--this script uses parameter ID instead of string (StringToHash function gets the ID)thisObject = Space.Host.ExecutingObjectparamID = thisObject.Animator.StringToHash("jumpHeight")OnClick=function()if thisObject.Animator.GetInteger(paramID ) ==0then thisObject.Animator.SetInteger(paramID , 1) else thisObject.Animator.SetInteger(paramID , 0) endendthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
-- when object is clicked, "clickedTrigger" trigger parameter will be set and initial trigger clearedthisObject = Space.Host.ExecutingObjectOnClick=function()thisObject.Animator.ResetTrigger("initialTrigger")thisObject.Animator.SetTrigger("clickedTrigger")endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
-- when object is clicked, "clickedTrigger" trigger parameter will be set and initial trigger clearedthisObject = Space.Host.ExecutingObjectinitialID = thisObject.Animator.StringToHash("initialTrigger")clickedID = thisObject.Animator.StringToHash("clickedTrigger")OnClick=function()thisObject.Animator.ResetTrigger(initialID)thisObject.Animator.SetTrigger(clickedID)endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
IsParameterControlledByCurve
bool IsParameterControlledByCurve (string name)
bool IsParameterControlledByCurve (int id)
Returns true if a parameter is controlled by an additional curve on an animation.
--clicking the object will toggle the Layer Weight of your second layer (index 1) between 0.0 and 1.0thisObject = Space.Host.ExecutingObjectOnClick=function()if thisObject.Animator.GetLayerWeight(1) ==0then thisObject.Animator.SetLayerWeight(1, 1.0)else thisObject.Animator.SetLayerWeight(1, 0.0)endendthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
void CrossFadeInFixedTime (string stateName, float transitionDuration, int layer)
void CrossFadeInFixedTime (string stateName, float transitionDuration, int layer, float fixedTime)
Creates a dynamic transition between the current state and the destination state. The duration and offset in the target state are in fixed time. stateName: The name of the destination state. transitionDuration: The duration of the transition. Value is in seconds. layer: Layer index containing the destination state. If no layer is specified or layer is -1, the first state that is found with the given name or hash will be played. fixedTime: Start time of the current destination state. Value is in seconds. If no explicit fixedTime is specified or fixedTime value is float.NegativeInfinity, the state will either be played from the start if it's not already playing, or will continue playing from its current time and no transition will happen.
--clicking the object will make it's animator crossfade from current state to the middle of "Second State" (on the second layer) in 3 secondsthisObject = Space.Host.ExecutingObjectOnClick=function()thisObject.Animator.CrossFadeInFixedTime("Second State", 3.0, 1, 0.5)endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
void CrossFade (string stateName, float transitionDuration, int layer)
void CrossFade (string stateName, float transitionDuration, int layer, float normalizedTime)
Creates a dynamic transition between the current state and the destination state. stateName: The name of the destination state. transitionDuration: The duration of the transition. Value is in source state normalized time. layer: Layer index containing the destination state. If no layer is specified or layer is -1, the first state that is found with the given name or hash will be played. normalizedTime: Start time of the current destination state. Value is in source state normalized time, should be between 0 and 1. If no explicit normalizedTime is specified or normalizedTime value is float.NegativeInfinity, the state will either be played from the start if it's not already playing, or will continue playing from its current time and no transition will happen.
--clicking the object will make it's animator crossfade from current state to the middle of "Second State" (on the second layer)--Crossfade duration will be triple the length of Source statethisObject = Space.Host.ExecutingObjectOnClick=function()thisObject.Animator.CrossFade("Second State", 3.0, 1, 0.5)endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
PlayInFixedTime
void PlayInFixedTime (string stateName, int layer) void PlayInFixedTime (string stateName) void PlayInFixedTime (string stateName, int layer, float fixedTime)
Plays a state. The offset in the target state is in fixed time. stateName: The name of the state to play. Layer index containing the destination state. If no layer is specified or layer is -1, the first state that is found with the given name or hash will be played.
--clicking the object will make it's animator play the "Second State", on the second Layer, and starting half a second inthisObject = Space.Host.ExecutingObjectOnClick=function()thisObject.Animator.PlayInFixedTime("Second State",1,0.5) --add "Second State" to the second Layer in Animator Controller endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
Play
void Play (string stateName)
void Play (string stateName, int layer)
void Play (string stateName, int layer, float normalizedTime)
Plays a state.
Parameter
Type
Description
stateName
string
The name of the state to play.
layer
int
Layer index containing the destination state. If no layer is specified or layer is -1, the first state that is found with the given name or hash will be played.
normalizedTime
float
Start time of the current destination state. Value is in normalized time. If no explicit normalizedTime is specified or value is float.NegativeInfinity, the state will either be played from the start if it's not already playing, or will continue playing from its current time.
Sets the animator in recording mode. The recording will continue until the user calls StopRecording. Maximum 10,000 frames. Note it is not possible to start playback until a call to StopRecording is made
Sets a trigger parameter to active. A trigger parameter is a bool parameter that gets reset to false when it has been used in a transition. For state machines with multiple layers, the trigger will only get reset once all layers have been evaluated, so that the layers can synchronize their transitions on the same parameter.
--clicking the object will make it's Animator damp transition it's "danceSpeed" property from 0.0 to 5.0thisObject = Space.Host.ExecutingObjectOnClick=function() Space.Host.StartCoroutine(function()while thisObject.Animator.GetFloat("danceSpeed") <5.0dothisObject.Animator.SetFloat("danceSpeed", 5.0, 1.0, Space.DeltaTime) coroutine.yield(0)endend)endthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
--clicking the object will toggle it's Animator's "jumpHeight" int parameter between 0 and 5thisObject = Space.Host.ExecutingObjectOnClick=function()if thisObject.Animator.GetInteger("jumpHeight") ==0then thisObject.Animator.SetInteger("jumpHeight", 1) else thisObject.Animator.SetInteger("jumpHeight", 0) endendthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
StringToHash
int StringToHash (string name)
Generates an parameter id from a string. Ids are used for optimized setters and getters on parameters.
Parameter
Type
Description
ID = Space.Host.ExecutingObject.Animator.StringToHash("isFlying")
--clicking the object will toggle it's "isFlying" bool parameter between true and false--this script uses parameter ID instead of string (StringToHash function gets the ID)thisObject = Space.Host.ExecutingObjectOnClick=function() parameterID = thisObject.Animator.StringToHash("isFlying")if thisObject.Animator.GetBool(parameterID) ==truethen thisObject.Animator.SetBool(parameterID, false) else thisObject.Animator.SetBool(parameterID, true) endendthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
-- when object is clicked, it's Animator's Avatar will be changed to an alternate onethisObject = Space.Host.ExecutingObjectalternateAvatar = Space.GetResource("altavatar") -- add Avatar to Scripting Runtime resources sectionOnClick=function()thisObject.Animator.Avatar = alternateAvatarendthisObject.AddClickable()thisObject.Clickable.OnClick(OnClick)
ApplyRootMotion
bool ApplyRootMotiongetset
Should root motion be applied?
Root motion is the effect where an object's entire mesh moves away from its starting point but that motion is created by the animation itself rather than by changing the Transform position.