# SAnimator

**الأعضاء** 39

|       |                                                               |                                                                                                                                                                                     |
| ----- | ------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| دالة  | [Rebind](#rebind)                                             | Rebind all the animated properties and mesh data with the Animator.                                                                                                                 |
| دالة  | [Stop](#stop)                                                 | Stop the Animator.                                                                                                                                                                  |
| دالة  | [SetTime](#settime)                                           | –                                                                                                                                                                                   |
| دالة  | [GetTime](#gettime)                                           | –                                                                                                                                                                                   |
| دالة  | [GetNormalizedTime](#getnormalizedtime)                       | Normalized time of the State.                                                                                                                                                       |
| دالة  | [GetLength](#getlength)                                       | Current duration of the state.                                                                                                                                                      |
| دالة  | [GetLoop](#getloop)                                           | Is the state looping.                                                                                                                                                               |
| دالة  | [GetFloat](#getfloat)                                         | Returns the value of the given float parameter. name: The name of the parameter. id: The id of the parameter.                                                                       |
| دالة  | [GetBool](#getbool)                                           | Returns the value of the given boolean parameter. name: The name of the parameter. id: The id of the parameter.                                                                     |
| دالة  | [GetInteger](#getinteger)                                     | Returns the value of the given integer parameter. name: The name of the parameter. id: The id of the parameter.                                                                     |
| دالة  | [ResetTrigger](#resettrigger)                                 | Resets the trigger parameter to false.                                                                                                                                              |
| دالة  | [IsParameterControlledByCurve](#isparametercontrolledbycurve) | Returns true if a parameter is controlled by an additional curve on an animation.                                                                                                   |
| دالة  | [GetLayerName](#getlayername)                                 | Gets name of the layer.                                                                                                                                                             |
| دالة  | [GetLayerIndex](#getlayerindex)                               | Gets the index of the layer with specified name.                                                                                                                                    |
| دالة  | [GetLayerWeight](#getlayerweight)                             | Gets the layer's current weight.                                                                                                                                                    |
| دالة  | [SetLayerWeight](#setlayerweight)                             | Sets the weight of the layer at the given index.                                                                                                                                    |
| دالة  | [IsInTransition](#isintransition)                             | Is the specified layer in a transition.                                                                                                                                             |
| دالة  | [CrossFadeInFixedTime](#crossfadeinfixedtime)                 | Creates a dynamic transition between the current state and the destination state.                                                                                                   |
| دالة  | [CrossFade](#crossfade)                                       | 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. |
| دالة  | [PlayInFixedTime](#playinfixedtime)                           | Plays a state.                                                                                                                                                                      |
| دالة  | [Play](#play)                                                 | Plays a state.                                                                                                                                                                      |
| دالة  | [StartPlayback](#startplayback)                               | Sets the animator in playback mode.                                                                                                                                                 |
| دالة  | [StopPlayback](#stopplayback)                                 | Stops the animator playback mode.                                                                                                                                                   |
| دالة  | [StartRecording](#startrecording)                             | Sets the animator in recording mode.                                                                                                                                                |
| دالة  | [StopRecording](#stoprecording)                               | Stops animator record mode.                                                                                                                                                         |
| دالة  | [Update](#update)                                             | –                                                                                                                                                                                   |
| دالة  | [SetTrigger](#settrigger)                                     | Sets a trigger parameter to active.                                                                                                                                                 |
| دالة  | [SetFloat](#setfloat)                                         | Send float values to the Animator to affect transitions. dampTime: The damper total time. deltaTime: The delta time to give to the damper.                                          |
| دالة  | [SetBool](#setbool)                                           | Sets the value of a boolean parameter.                                                                                                                                              |
| دالة  | [SetInteger](#setinteger)                                     | Sets the value of the given integer parameter.                                                                                                                                      |
| دالة  | [StringToHash](#stringtohash)                                 | Generates an parameter id from a string.                                                                                                                                            |
| دالة  | [GetCurrentAnimatorStateInfo](#getcurrentanimatorstateinfo)   | Returns an SAnimatorStateInfo with the information on the current state..                                                                                                           |
| خاصية | [Controller](#controller)                                     | The Animator Controller resource of this Animator                                                                                                                                   |
| خاصية | [Avatar](#avatar)                                             | Gets/Sets the current Avatar.                                                                                                                                                       |
| خاصية | [ApplyRootMotion](#applyrootmotion)                           | Should root motion be applied?                                                                                                                                                      |
| خاصية | [PlaybackTime](#playbacktime)                                 | –                                                                                                                                                                                   |
| خاصية | [Enabled](#enabled)                                           | Whether the Animator component is enabled or not                                                                                                                                    |
| خاصية | [Parameters](#parameters)                                     | The AnimatorControllerParameter list used by the animator.                                                                                                                          |
| خاصية | [GameObject](#gameobject)                                     | Returns a reference to the GameObject of this component.                                                                                                                            |

## الدوال

### Rebind

void Rebind()

Rebind all the animated properties and mesh data with the Animator.

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.Rebind()

```

### Stop

void Stop()

Stop the Animator.

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.Stop()

```

### SetTime

void SetTime(double time)

المعاملات

| الاسم | النوع  | القيمة الافتراضية |
| ----- | ------ | ----------------- |
| time  | double | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.SetTime(1.0)

```

### GetTime

double GetTime()

القيم المرجعة

`double`

مثال

**Lua**

```lua
layerStateTime = Space.Host.ExecutingObject.Animator.GetTime(0)

```

### GetNormalizedTime

double GetNormalizedTime(int layer = 0)

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.

المعاملات

| الاسم | النوع | القيمة الافتراضية |
| ----- | ----- | ----------------- |
| layer | int   | 0                 |

القيم المرجعة

`double`

مثال

**Lua**

```lua
layerStateNormalizedTime = Space.Host.ExecutingObject.Animator.GetNormalizedTime(0)

```

### GetLength

double GetLength(int layer = 0)

Current duration of the state.

المعاملات

| الاسم | النوع | القيمة الافتراضية |
| ----- | ----- | ----------------- |
| layer | int   | 0                 |

القيم المرجعة

`double`

مثال

**Lua**

```lua
layerStateLength = Space.Host.ExecutingObject.Animator.GetLength(1)

```

### GetLoop

bool GetLoop(int layer = 0)

Is the state looping.

المعاملات

| الاسم | النوع | القيمة الافتراضية |
| ----- | ----- | ----------------- |
| layer | int   | 0                 |

القيم المرجعة

`bool`

مثال

**Lua**

```lua
layerStateLoop = Space.Host.ExecutingObject.Animator.GetLoop(0)

```

### GetFloat

float GetFloat(string name)

float GetFloat(int id)

Returns the value of the given float parameter. name: The name of the parameter. id: The id of the parameter.

المعاملات

| الاسم | النوع  | القيمة الافتراضية |
| ----- | ------ | ----------------- |
| name  | string | –                 |
| id    | int    | –                 |

القيم المرجعة

`float`

مثال

**Lua**

```lua
getParam = Space.Host.ExecutingObject.Animator.GetFloat("paramName")

-- or 

 paramID = Space.Host.ExecutingObject.Animator.StringToHash("paramName")
getParam = Space.Host.ExecutingObject.Animator.GetFloat(paramID)

```

**Lua**

```lua
--clicking the object will toggle it's Animator's "flySpeed" float parameter between 0.0 and 5.0
thisObject = Space.Host.ExecutingObject

OnClick = function()
if thisObject.Animator.GetFloat("flySpeed") == 0.0 then
  thisObject.Animator.SetFloat("flySpeed", 5.0) 
else 
  thisObject.Animator.SetFloat("flySpeed", 0.0) 
end

end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)

```

**Lua**

```lua
--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.ExecutingObject
paramID = thisObject.Animator.StringToHash("flySpeed")

OnClick = function()
if thisObject.Animator.GetFloat(paramID) == 0.0 then
  thisObject.Animator.SetFloat(paramID, 5.0) 
else 
  thisObject.Animator.SetFloat(paramID, 0.0) 
end

end
thisObject.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.

المعاملات

| الاسم | النوع  | القيمة الافتراضية |
| ----- | ------ | ----------------- |
| name  | string | –                 |
| id    | int    | –                 |

القيم المرجعة

`bool`

مثال

**Lua**

```lua
isFlying = Space.Host.ExecutingObject.Animator.GetBool("IsFlying")

--or

ID = Space.Host.ExecutingObject.Animator.StringToHash("isFlying")
isFlying = Space.Host.ExecutingObject.Animator.GetBool(ID)

```

**Lua**

```lua
--clicking the object will toggle it's "isFlying" bool parameter between true and false
thisObject = Space.Host.ExecutingObject

OnClick = function()
if thisObject.Animator.GetBool("isFlying") == true then
  thisObject.Animator.SetBool("isFlying", false) 
else 
  thisObject.Animator.SetBool("isFlying", true) 
end

end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)

```

**Lua**

```lua
--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.ExecutingObject

OnClick = function()
  parameterID = thisObject.Animator.StringToHash("isFlying")
  
if thisObject.Animator.GetBool(parameterID) == true then
  thisObject.Animator.SetBool(parameterID, false) 
else 
  thisObject.Animator.SetBool(parameterID, true) 
end

end
thisObject.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.

المعاملات

| الاسم | النوع  | القيمة الافتراضية |
| ----- | ------ | ----------------- |
| name  | string | –                 |
| id    | int    | –                 |

القيم المرجعة

`int`

مثال

**Lua**

```lua
getParam = Space.Host.ExecutingObject.Animator.GetInteger("paramName")
--or
 paramID = Space.Host.ExecutingObject.Animator.StringToHash("paramName")
getParam = Space.Host.ExecutingObject.Animator.GetInteger(paramID)

```

**Lua**

```lua
--clicking the object will toggle it's Animator's "jumpHeight" int parameter between 0 and 5

thisObject = Space.Host.ExecutingObject

OnClick = function()
if thisObject.Animator.GetInteger("jumpHeight") == 0 then
  thisObject.Animator.SetInteger("jumpHeight", 1) 
else 
  thisObject.Animator.SetInteger("jumpHeight", 0) 
end

end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)

```

**Lua**

```lua
--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.ExecutingObject
paramID = thisObject.Animator.StringToHash("jumpHeight")

OnClick = function()
if thisObject.Animator.GetInteger(paramID ) == 0 then
  thisObject.Animator.SetInteger(paramID , 1) 
else 
  thisObject.Animator.SetInteger(paramID , 0) 
end

end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)

```

### ResetTrigger

void ResetTrigger(string name)

void ResetTrigger(int id)

Resets the trigger parameter to false.

المعاملات

| الاسم | النوع  | القيمة الافتراضية |
| ----- | ------ | ----------------- |
| name  | string | –                 |
| id    | int    | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.ResetTrigger("parameterName")
--or
paramID = Space.Host.ExecutingObject.Animator.StringToHash("parameterName")
Space.Host.ExecutingObject.Animator.ResetTrigger(paramID)

```

**Lua**

```lua
-- when object is clicked, "clickedTrigger" trigger parameter will be set and initial trigger cleared
thisObject = Space.Host.ExecutingObject


OnClick = function()
thisObject.Animator.ResetTrigger("initialTrigger")
thisObject.Animator.SetTrigger("clickedTrigger")
end
  

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)

```

**Lua**

```lua
-- when object is clicked, "clickedTrigger" trigger parameter will be set and initial trigger cleared
thisObject = Space.Host.ExecutingObject

initialID = thisObject.Animator.StringToHash("initialTrigger")
clickedID = thisObject.Animator.StringToHash("clickedTrigger")

OnClick = function()
thisObject.Animator.ResetTrigger(initialID)
thisObject.Animator.SetTrigger(clickedID)
end
  

thisObject.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.

المعاملات

| الاسم | النوع  | القيمة الافتراضية |
| ----- | ------ | ----------------- |
| name  | string | –                 |
| id    | int    | –                 |

القيم المرجعة

`bool`

مثال

**Lua**

```lua
paramCurve = Space.Host.ExecutingObject.Animator.IsParameterControlledByCurve("parameterName")

```

### GetLayerName

string GetLayerName(int layerIndex)

Gets name of the layer.

المعاملات

| الاسم      | النوع | القيمة الافتراضية |
| ---------- | ----- | ----------------- |
| layerIndex | int   | –                 |

القيم المرجعة

`string`

مثال

**Lua**

```lua
layerName = Space.Host.ExecutingObject.Animator.GetLayerName(1)

```

### GetLayerIndex

int GetLayerIndex(string layerName)

Gets the index of the layer with specified name.

المعاملات

| الاسم     | النوع  | القيمة الافتراضية |
| --------- | ------ | ----------------- |
| layerName | string | –                 |

القيم المرجعة

`int`

مثال

**Lua**

```lua
layerIndex = Space.Host.ExecutingObject.Animator.GetLayerIndex("Layer Name")

```

### GetLayerWeight

float GetLayerWeight(int layerIndex)

Gets the layer's current weight.

المعاملات

| الاسم      | النوع | القيمة الافتراضية |
| ---------- | ----- | ----------------- |
| layerIndex | int   | –                 |

القيم المرجعة

`float`

مثال

**Lua**

```lua
layerIndex = Space.Host.ExecutingObject.Animator.GetLayerWeight("Layer Name")

```

### SetLayerWeight

void SetLayerWeight(int layerIndex, float weight)

Sets the weight of the layer at the given index.

المعاملات

| الاسم      | النوع | القيمة الافتراضية |
| ---------- | ----- | ----------------- |
| layerIndex | int   | –                 |
| weight     | float | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.SetLayerWeight(0,2.0)

```

**Lua**

```lua
--clicking the object will toggle the Layer Weight of your second layer (index 1) between 0.0 and 1.0

thisObject = Space.Host.ExecutingObject

OnClick = function()
if thisObject.Animator.GetLayerWeight(1) == 0 then
  thisObject.Animator.SetLayerWeight(1, 1.0)
else 
  thisObject.Animator.SetLayerWeight(1, 0.0)
end

end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)

```

### IsInTransition

bool IsInTransition(int layerIndex)

Is the specified layer in a transition.

المعاملات

| الاسم      | النوع | القيمة الافتراضية |
| ---------- | ----- | ----------------- |
| layerIndex | int   | –                 |

القيم المرجعة

`bool`

مثال

**Lua**

```lua
layerTransition = Space.Host.ExecutingObject.Animator.IsInTransition(0)

```

### CrossFadeInFixedTime

void CrossFadeInFixedTime(string stateName, float transitionDuration)

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.

المعاملات

| الاسم              | النوع  | القيمة الافتراضية |
| ------------------ | ------ | ----------------- |
| stateName          | string | –                 |
| transitionDuration | float  | –                 |
| layer              | int    | –                 |
| fixedTime          | float  | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.CrossFadeInFixedTime("State Name", 15.0)
Space.Host.ExecutingObject.Animator.CrossFadeInFixedTime("State Name", 15.0, 0)
Space.Host.ExecutingObject.Animator.CrossFadeInFixedTime("State Name", 15.0, 0 , 0.0)

```

**Lua**

```lua
--clicking the object will make it's animator crossfade from current state to the middle of "Second State" (on the second layer) in 3 seconds
thisObject = Space.Host.ExecutingObject

OnClick = function()
thisObject.Animator.CrossFadeInFixedTime("Second State", 3.0, 1, 0.5)
end

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)

```

### CrossFade

void CrossFade(string stateName, float transitionDuration)

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.

المعاملات

| الاسم              | النوع  | القيمة الافتراضية |
| ------------------ | ------ | ----------------- |
| stateName          | string | –                 |
| transitionDuration | float  | –                 |
| layer              | int    | –                 |
| normalizedTime     | float  | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.CrossFade("State Name", 3.0)
Space.Host.ExecutingObject.Animator.CrossFade("State Name", 3.0, 0)
Space.Host.ExecutingObject.Animator.CrossFade("State Name", 3.0, 0 , 0.0)

```

**Lua**

```lua
--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 state
thisObject = Space.Host.ExecutingObject

OnClick = function()
thisObject.Animator.CrossFade("Second State", 3.0, 1, 0.5)
end

thisObject.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.

المعاملات

| الاسم     | النوع  | القيمة الافتراضية |
| --------- | ------ | ----------------- |
| stateName | string | –                 |
| layer     | int    | –                 |
| fixedTime | float  | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.PlayInFixedTime("State Name")
Space.Host.ExecutingObject.Animator.PlayInFixedTime("State Name", 0)
Space.Host.ExecutingObject.Animator.PlayInFixedTime("State Name", 0, 0.0)

```

**Lua**

```lua
--clicking the object will make it's animator play the "Second State", on the second Layer, and starting half a second in
thisObject = Space.Host.ExecutingObject

OnClick = function()
thisObject.Animator.PlayInFixedTime("Second State",1,0.5) --add "Second State" to the second Layer in Animator Controller 
end


thisObject.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.

المعاملات

| المعامل        | النوع  | الوصف                                                                                                                                                                                                                                                                                |
| -------------- | ------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| 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. |

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.Play("Run")
Space.Host.ExecutingObject.Animator.Play("Run", 0)
Space.Host.ExecutingObject.Animator.Play("Run", 0, 0.5)

```

### StartPlayback

void StartPlayback()

Sets the animator in playback mode.

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.StartPlayback()

```

### StopPlayback

void StopPlayback()

Stops the animator playback mode. When playback stops, the avatar resumes getting control from game logic.

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.StopPlayback()

```

### StartRecording

void StartRecording()

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

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.StartRecording()

```

### StopRecording

void StopRecording()

Stops animator record mode.

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.StopRecording()

```

### Update

void Update(float deltaTime)

المعاملات

| الاسم     | النوع | القيمة الافتراضية |
| --------- | ----- | ----------------- |
| deltaTime | float | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.Update()

```

### SetTrigger

void SetTrigger(string trigger)

void SetTrigger(int id)

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.

المعاملات

| الاسم   | النوع  | القيمة الافتراضية |
| ------- | ------ | ----------------- |
| trigger | string | –                 |
| id      | int    | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.SetTrigger("TheTriggerName")
--or
paramID = Space.Host.ExecutingObject.Animator.StringToHash("TheTriggerName")
Space.Host.ExecutingObject.SetTrigger(paramID)

```

### SetFloat

void SetFloat(string name, float value)

void SetFloat(string name, float value, float dampTime, float deltaTime)

void SetFloat(int id, float value)

void SetFloat(int id, float value, float dampTime, float deltaTime)

Send float values to the Animator to affect transitions. dampTime: The damper total time. deltaTime: The delta time to give to the damper.

المعاملات

| الاسم     | النوع  | القيمة الافتراضية |
| --------- | ------ | ----------------- |
| name      | string | –                 |
| value     | float  | –                 |
| dampTime  | float  | –                 |
| deltaTime | float  | –                 |
| id        | int    | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
 Space.Host.ExecutingObject.Animator.SetFloat("parameterName", 2.2)
--or
Space.Host.ExecutingObject.Animator.SetFloat("parameterName", 2.2,2.0,Space.DeltaTime)
--or
paramID = Space.Host.ExecutingObject.Animator.StringToHash("parameterName")
Space.Host.ExecutingObject.Animator.SetFloat(paramID, 2.2)
--or
paramID = Space.Host.ExecutingObject.Animator.StringToHash("parameterName")
Space.Host.ExecutingObject.Animator.SetFloat(paramID, 2.2,2.0,Space.DeltaTime)

```

**Lua**

```lua
--clicking the object will make it's Animator damp transition it's "danceSpeed" property from 0.0 to 5.0

thisObject = Space.Host.ExecutingObject

OnClick = function()
  Space.Host.StartCoroutine(function()
      while thisObject.Animator.GetFloat("danceSpeed") < 5.0 do
thisObject.Animator.SetFloat("danceSpeed", 5.0, 1.0, Space.DeltaTime) 
coroutine.yield(0)
      end

end)
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)

```

### SetBool

void SetBool(int id, bool value)

void SetBool(string name, bool value)

Sets the value of a boolean parameter.

المعاملات

| الاسم | النوع  | القيمة الافتراضية |
| ----- | ------ | ----------------- |
| id    | int    | –                 |
| value | bool   | –                 |
| name  | string | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.SetBool("IsFlying", true)
--or
paramID = Space.Host.ExecutingObject.Animator.StringToHash("parameterName")
Space.Host.ExecutingObject.Animator.SetFloat(paramID, 2.2)

```

**Lua**

```lua
--clicking the object will toggle it's "isFlying" bool parameter between true and false
thisObject = Space.Host.ExecutingObject

OnClick = function()
if thisObject.Animator.GetBool("isFlying") == true then
  thisObject.Animator.SetBool("isFlying", false) 
else 
  thisObject.Animator.SetBool("isFlying", true) 
end

end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)

```

### SetInteger

void SetInteger(string name, int value)

void SetInteger(int id, int value)

Sets the value of the given integer parameter.

المعاملات

| الاسم | النوع  | القيمة الافتراضية |
| ----- | ------ | ----------------- |
| name  | string | –                 |
| value | int    | –                 |
| id    | int    | –                 |

القيم المرجعة

`void`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.SetInteger("iParam", 2)
--or
paramID = Space.Host.ExecutingObject.Animator.StringToHash("iParam")
Space.Host.ExecutingObject.Animator.SetInteger(paramID, 2)

```

**Lua**

```lua
--clicking the object will toggle it's Animator's "jumpHeight" int parameter between 0 and 5

thisObject = Space.Host.ExecutingObject

OnClick = function()
if thisObject.Animator.GetInteger("jumpHeight") == 0 then
  thisObject.Animator.SetInteger("jumpHeight", 1) 
else 
  thisObject.Animator.SetInteger("jumpHeight", 0) 
end

end
thisObject.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.

المعاملات

| الاسم | النوع  | القيمة الافتراضية |
| ----- | ------ | ----------------- |
| name  | string | –                 |

القيم المرجعة

`int`

مثال

**Lua**

```lua
ID = Space.Host.ExecutingObject.Animator.StringToHash("isFlying")

```

**Lua**

```lua
--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.ExecutingObject

OnClick = function()
  parameterID = thisObject.Animator.StringToHash("isFlying")
  
if thisObject.Animator.GetBool(parameterID) == true then
  thisObject.Animator.SetBool(parameterID, false) 
else 
  thisObject.Animator.SetBool(parameterID, true) 
end

end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)

```

### GetCurrentAnimatorStateInfo

[SAnimatorStateInfo](/docs/ar/scripting/client-scripting-api-reference/types/sanimatorstateinfo.md) GetCurrentAnimatorStateInfo(int Layerindex)

Returns an SAnimatorStateInfo with the information on the current state..

المعاملات

| الاسم      | النوع | القيمة الافتراضية |
| ---------- | ----- | ----------------- |
| Layerindex | int   | –                 |

القيم المرجعة

`SAnimatorStateInfo`

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.GetCurrentAnimationStateInfo(0)

```

## الخصائص

### Controller

[SResource](/docs/ar/scripting/client-scripting-api-reference/types/sresource.md) Controller {get; set; }

The Animator Controller resource of this Animator

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.Controller = Space.GetResource("newController")

```

### Avatar

[SResource](/docs/ar/scripting/client-scripting-api-reference/types/sresource.md) Avatar {get; set; }

Gets/Sets the current Avatar.

مثال

**Lua**

```lua
currentAvatar = thisObject.Animator.Avatar 

```

**Lua**

```lua
-- when object is clicked, it's Animator's Avatar will be changed to an alternate one
thisObject = Space.Host.ExecutingObject

alternateAvatar = Space.GetResource("altavatar") -- add Avatar to Scripting Runtime resources section

OnClick = function()
thisObject.Animator.Avatar = alternateAvatar
end
  

thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClick)

```

### ApplyRootMotion

bool ApplyRootMotion {get; set; }

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.

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.ApplyRootMotion = true

```

**Lua**

```lua
--clicking this object will Enable/Disable it's Root Motion
thisGameObject = Space.Host.ExecutingObject.Animator


OnClick = function()
animator.ApplyRootMotion =  not animator.ApplyRootMotion
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

```

### PlaybackTime

float PlaybackTime {get; set; }

مثال

**Lua**

```lua
pace.Host.ExecutingObject.Animator.PlaybackTime = 0.5

```

### Enabled

bool Enabled {get; set; }

Whether the Animator component is enabled or not

مثال

**Lua**

```lua
Space.Host.ExecutingObject.Animator.Enabled = true

```

**Lua**

```lua
--clicking this object will Enable/Disable it's Animator component
thisGameObject = Space.Host.ExecutingObject
animator = thisGameObject.Animator


OnClick = function()
animator.Enabled =  not animator.Enabled
end


thisGameObject.AddClickable()
thisGameObject.Clickable.OnClick(OnClick)

```

### Parameters

string\[] Parameters {get; }

The AnimatorControllerParameter list used by the animator.

مثال

**Lua**

```lua
parameters = Space.Host.ExecutingObject.Animator.Parameters
for i=1,#parameters do Space.Log(parameters[i]) end --prints all parameters

```

### GameObject

[SGameObject](/docs/ar/scripting/client-scripting-api-reference/types/sgameobject.md) GameObject {get; }

Returns a reference to the GameObject of this component.

مثال

**Lua**

```lua
theGameObject = Space.Host.ExecutingObject.Animator.GameObject

```
