AddTorqueToPrefabInstance

Definition

AddTorqueToPrefabInstance(string prefabInstanceName, float torqueX, float torqueY, float torqueZ, float torquePower)

Description

This function applies torque to the prefab instance that has dynamic physics. 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 that has dynamic physics. 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.

torqueX, torqueY, torqueZ
These three values determine the direction of the torque that is applied to prefab instance. Vanda Engine normalizes the vector (torqueX, torqueY, torqueZ).

torquePower
Determines the strength of the torque.

Example 1

function Init()
     AddTorqueToPrefabInstance("1_VandaEngine17-SamplePack1_f1_barrel", 1.0, 1.0, 1.0, 15.0)
end

function Update()

end
This function applies a torque of 15.0 units in the normalized direction (1.0, 1.0, 1.0) to the “1_VandaEngine17-SamplePack1_f1_barrel” prefab instance.

Example 2

--name of the script is addtorquetoprefabinstance2.lua
function Init()
     AddTorqueToPrefabInstance("this", 1.0, 0.0, 0.0, 10.0)
end

function Update()

end
If, in the Prefab Editor, you attach addtorquetoprefabinstance2.lua script to a Prefab, then “this” parameter in the AddTorqueToPrefabInstance 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 AddTorqueToPrefabInstance function refers to the name instance1_a.
This function applies a torque of 10.0 units in the normalized direction (1.0, 0.0, 0.0) to the current prefab instance.
adminAddTorqueToPrefabInstance