Definition
double GetPrefabInstanceRadius(string prefabInstanceName)
Description
This function receives the name of the prefab instance prefabInstanceName and returns its approximate radius.
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
Returns approximate radius of prefab instance prefabInstanceName.
Example 1
radius = 0.0 function Init() radius = GetPrefabInstanceRadius("1_VandaEngine17-SamplePack1_well") message = string.format("\nPrefab instance radius is > %.2f" ,radius) PrintConsole(message) end function Update() end
First, the GetPrefabInstanceRadius function returns the approximate radius of “1_VandaEngine17-SamplePack1_well”. Then we display the radius value in the console using the PrintConsole function.
Example 2
--Name of script is GetPrefabInstanceRadius2.lua radius = 0.0 function Init() radius = GetPrefabInstanceRadius("this") message = string.format("\nPrefab instance radius is > %.2f" ,radius) PrintConsole(message) end function Update() end
If, in the Prefab Editor, you attach GetPrefabInstanceRadius2.lua script to a Prefab, then “this” parameter in the GetPrefabInstanceRadius 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 a to which this script is attached, “this” in GetPrefabInstanceRadius function refers to the name instance1_a.
In this example, GetPrefabInstanceRadius function returns the approximate radius of current prefab instance (for example, instance1_a). Then we display the radius value in the console using the PrintConsole function.
GetPrefabInstanceRadius