ExecuteCyclicAnimation 

Definition

ExecuteCyclicAnimation(string prefabInstanceName, string animationClipName, float weightTarget, float delayIn)

Description

ExecuteCyclicAnimation adjusts the weight of a cyclic animation of prefab instance in a given amount of time. This can be used to fade in a new cycle or to modify the weight of an active cycle.

Parameters

prefabInstanceName
Specifies the name of the prefab instance. You can also use the name “this” for this parameter. In this case, “this” refers to the prefab instance that this script is attached to.

animationClipName
Specifies the name of the prefab instance animation. To view the name of the prefab instance animations, you can go to the Modify > Properties menu in the prefab editor, or select the name of the prefab instance from the Prefabs and GUIs section in the current VScene and press the Edit button.

weightTarget
Specifies the final weight of the animation clip animationClipName. A value of 1 means full animation and a value of 0 means no animation.

delayIn
Specifies when the animationClipName reaches the weightTarget weight.

Example 1

function Init()
    ExecuteCyclicAnimation("1_animation_test_boy""defaultClip", 1.0, 0.5)
end

function Update()

end
In the first 0.5 seconds, the “defaultClip” animation value of prefab instance “1_animation_test_boy” goes from weight 0 to weight 1.0 (full animation).

Example 2

animation = true

function Init()

end

function Update()
     if animation == true then 
          ExecuteCyclicAnimation("this", "run", 0.3, 1.0) 
          animation = false
     end
end
If, in the Prefab Editor, you attach executecyclicanimation2.lua script to a Prefab that has an animation clip “run”, then “this” parameter in the ExecuteCyclicAnimation function will point to instances of that Prefab in current VScene. For example, if you have an Instance named instance1_a from a Prefab named to which this script is attached, “this” in ExecuteCyclicAnimation function refers to the name instance1_a. In this case, In the first 1.0 seconds, the “run” animation value of prefab instance instance1_a goes from weight 0 to weight 0.3 (30% of animation “run”).
adminExecuteCyclicAnimation