ResumePrefabInstanceAnimations

Definition

ResumePrefabInstanceAnimations(string prefabInstanceName)

Description

This function resumes all animations of the prefab instance prefabInstanceName. To view the name of prefab instances, open the VScene and click on the desired Prefab Instance in the “Prefabs and GUIs” section and press the Edit button. You can also access the names of prefab instances from the Script Utility section of the script editor ( Tools > Script Editor > Tools > Script Utility). In the dialog that appears, you can view and copy the name of the prefab instance.

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.

Example 1

function OnTriggerEnter(otherActorName)
    --nil means main character controller
    if otherActorName == nil then
          PausePrefabInstanceAnimations("1_animation_test_plane")
    end
end

function OnTriggerStay(otherActorName)

end

function OnTriggerExit(otherActorName)
    --nil means main character controller
    if otherActorName == nil then
          ResumePrefabInstanceAnimations("1_animation_test_plane")
    end
end
Assume that the above script is attached to a trigger named trigger1. Whenever the main character enters “trigger1”, all animations of prefab instance “1_animation_test_plane” will be paused. Whenever the main character exits “trigger1”, all animations of prefab instance “1_animation_test_plane” will be resumed.

Example 2

--Name of script is ResumePrefabInstanceAnimations2.lua

pause_animation = true
time = 0.0

function Init()
    PausePrefabInstanceAnimations("this")
end

function Update()
    time = time + GetElapsedTime()
    if pause_animation and time >= 5.0 then
          ResumePrefabInstanceAnimations("this")
          pause_animation = false
    end
end
If, in the Prefab Editor, you attach ResumePrefabInstanceAnimations2.lua script to a Prefab, then “this” parameter in the ResumePrefabInstanceAnimations 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 ResumePrefabInstanceAnimations function refers to the name instance1_a.
In this example, assume that the above script is attached to a prefab named and we have an instance of it named instance1_a. first in the Init() event, we pause all animations of the current prefab instance named instance_a. Then, in the Update() event, after 5.0 seconds we resume all animations of the current prefab instance named instance_a.
adminResumePrefabInstanceAnimations