GetPrefabInstanceRotate

Definition

double,double,double GetPrefabInstanceRotate(string prefabInstanceName)

Description

This function receives the name of the prefab instance prefabInstanceName and returns its rotation as three values x, y and z.

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.

Return Value

This function returns the prefab instance rotation as three values x, y and z.

Example 1

rotateX = 0.0
rotateY = 0.0
rotateZ = 0.0

function Init()
    rotateX, rotateY, rotateZ = GetPrefabInstanceRotate("1_VandaEngine17-SamplePack1_well")

    message = string.format("\nPrefab instance rotation is > (%.2f, %.2f, %.2f)" , rotateX, rotateY, rotateZ)
    PrintConsole(message)
end

function Update()

end
First, GetPrefabInstanceRotate function returns the rotation of “1_VandaEngine17-SamplePack1_well”. Then we display the rotation values in the console using the PrintConsole function.

Example 2

--Name of script is GetPrefabInstanceRotate2.lua

rotateX = 0.0
rotateY = 0.0
rotateZ = 0.0

function Init()
    rotateX, rotateY, rotateZ = GetPrefabInstanceRotate("this")

    message = string.format("\nPrefab instance rotation is > (%.2f, %.2f, %.2f)" , rotateX, rotateY, rotateZ)
    PrintConsole(message)
end

function Update()

end
If, in the Prefab Editor, you attach GetPrefabInstanceRotate2.lua script to a Prefab, then “this” parameter in the GetPrefabInstanceRotate 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 GetPrefabInstanceRotate function refers to the name instance1_a.
In this example, GetPrefabInstanceRotate function returns the rotation of current prefab instance (for example, instance1_a). Then we display the rotation values in the console using the PrintConsole function.
adminGetPrefabInstanceRotate