SimLab Composer’s Training Builder uses Lua scripting language. Our API allows users to create Lua scripts for their specific needs, making the tool a dynamic platform for creativity and innovation.
Lua scripting in SimLab Training Builder enables advanced users to create complex, feature-rich experiences beyond default capabilities. It allows precise customization of training scenarios with unique functionalities for immersive outcomes, offering limitless creativity.
Lua Scripting is only available in the Ultimate edition of SimLab Composer 12.1 or later and is not included in SimLab VR Studio.
To execute a Lua script in SimLab Training Builder, create a ‘Run Script’ node graph by right-clicking and selecting ‘Run Script’. This node allows Lua script input and must be linked into your graph execution flow.
print
FunctionThe print("Hello World!")
function is crucial for script writing and testing in Lua. It tracks data flow and variable states, aids in issue identification, and acts as a simple logging system for debugging and understanding code behavior.
Variable
, variable
, and VARIABLE
are all considered different identifiers in Lua.;
at the end of each statement.--
at the start of the line. For commenting out multiple lines, start with --[[
on the first line and end with ]]
on the final line.Please be aware that improper use of Lua scripting can lead to unexpected crashes in SimLab VR Viewer. Always test your scripts thoroughly before running them in production. If you encounter consistent crashes, consider reaching out to the SimLab community or support for assistance. Your understanding and caution are appreciated. Happy scripting!
Represents a Lua Manager for SimLab VR Viewer.
Find nodes in the scene by name.
(string)
The name of the nodes to search for.
Array<ASimLabTransformNode>
:
An array of nodes matching the given name.
-- Find all airplane objects in scene
AirPlanesArray = SimLabUtils:FindNodesByName("AirPlane")
Find nodes in the scene by attribute name.
(string)
The name of the attribute to search for.
Array<ASimLabTransformNode>
:
An array of nodes with the specified attribute.
-- Find all airplane objects in scene
AirPlanesArray = SimLabUtils:FindNodesByAttribute("AirPlane")
Find animation sequences in the scene by name.
(string)
The name of the animation sequences to search for.
Array<ASimLabAnimationSequence>
:
An array of animation sequences matching the given name.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:SetPlayRange(0, 100)
Find scene states in the scene by name.
(string)
The name of the scene states to search for.
Array<ASimLabSceneState>
:
An array of scene states matching the given name.
local SceneStates = SimLabUtils:FindSceneStatesByName("Mid")
local SceneState = SceneStates[1]
print(SceneState:GetSceneStateName())
SceneState:Apply()
Import a VR package from a path or URL with a specified transform into the current scene.
(string)
The path or URL of the VR package.
(FTransform)
The transform to apply during import.
-- Add box to scene
SimLabUtils:ImportVRPackage("C:/Box.vrpackage", UE.FTransform(UE.FRotator(0, 0, 0), UE.FVector(0, 0, 0), UE.FVector(1, 1, 1)))
Get a variable by name.
(string)
The name of the variable to retrieve.
UEventsVariable
:
The variable with the specified name.
local NumVariable = SimLabUtils:GetVariableByName("num")
NumVariable:SetNumberValue(num + 2)
Get the first player controller.
ASimLabController
:
The first player controller.
local Player = SimLabUtils:GetFirstPlayerController()
local CameraTransform = Player:GetCameraTransform()
Create a new HTTP request.
USimLabLuaHttpRequest
:
A new HTTP request object.
-- New Rest API request object
HttpRequest = SimLabUtils:NewHttpRequest()
Create a new JSON object.
USimLabLuaJsonObject
:
A new JSON object.
-- New JSON object
JSON_Object = SimLabUtils:NewJsonObject()
Create a new JSON value.
USimLabLuaJsonValue
:
A new JSON value.
-- New JSON value
local OutJSONArray1 = SimLabUtils:NewJsonValue()
Represents a 3D Object Node in Lua.
Get the material associated with this object node.
ASimLabMaterial
:
The material for this object node.
local Nodes1 = SimLabUtils:FindNodesByName("3DBox")
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
Set the material for this object node.
(ASimLabMaterial)
The new material to set.
local Nodes1 = SimLabUtils:FindNodesByName("3DBox")
local Box = Nodes1[1]
local Nodes2 = SimLabUtils:FindNodesByName("3DSphere")
local Sphere = Nodes2[1]
local BoxMaterial = Box:GetMaterial()
local SphereMaterial = Sphere:GetMaterial()
print(BoxMaterial:GetMaterialName())
print(SphereMaterial:GetMaterialName())
Box:SetMaterial(SphereMaterial)
Sphere:SetMaterial(BoxMaterial)
Represents a 3D Sound Node in Lua.
Toggle the playback state of the sound.
local SoundNodes = SimLabUtils:FindNodesByAttribute("SoundNode")
SoundNodes[1]:ToggleState()
Start playing the sound.
local SoundNodes = SimLabUtils:FindNodesByAttribute("SoundNode")
SoundNode[1]:Play()
Stop the sound playback.
local SoundNodes = SimLabUtils:FindNodesByAttribute("SoundNode")
SoundNodes[1]:Stop()
Represents a Player Controller (The object that's used to control the player's character) in Lua.
Get the camera's transform.
FTransform
:
The camera's transform.
local Player = SimLabUtils:GetFirstPlayerController()
local CameraTransform = Player:GetCameraTransform()
print(tostring(CameraTransform))
local CameraRotation = CameraTransform.Rotation
print(tostring(CameraRotation))
local CameraLocation = CameraTransform.Translation
print(tostring(CameraLocation))
local ForwardVector = CameraRotation:GetForwardVector()
local NewLocation = CameraLocation + ForwardVector * -3;
Point the controller to a specified object node.
(ASimLabTransformNode)
The object node to point to.
local Controller = SimLabUtils:GetFirstPlayerController()
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
Controller:PointToNode(Nodes[1])
Remove the pointed object association from the controller.
local Controller = SimLabUtils:GetFirstPlayerController()
Controller:RemovePointToNode()
Teleport the controller to a specified view position and orientation.
(FVector)
The eye position to teleport to.
(FRotator)
The rotation of the view.
local Controller = SimLabUtils:GetFirstPlayerController()
Controller:TeleportToView(UE.FVector(0, 0, 0), UE.FRotator(0, 0, 0))
Teleport the controller to a specified location.
(FVector)
The eye position to teleport to.
local Controller = SimLabUtils:GetFirstPlayerController()
Controller:TeleportToLocation(UE.FVector(0, 0, 0))
Represents a Lua HTTP Request in Lua.
Set the request body with a JSON object. In the example we create a new JSON object and set the username and password of the user, then we assign it to the new HTTP request using
(USimLabLuaJsonObject)
The JSON object to set as the request body.
JSON_Object = SimLabUtils:NewJsonObject()
JSON_Object:SetStringField("username", "SimLab123")
JSON_Object:SetStringField("password", "Pass123")
HttpRequest = SimLabUtils:NewHttpRequest()
HttpRequest:SetRequestBody(JSON_Object)
Process the HTTP request. Parameters allowed:
HttpRequest = SimLabUtils:NewHttpRequest()
HttpRequest:SetVerb("GET")
HttpRequest:SetEndpoint("http://api.apilayer.com/exchangerates_data/timeser
ies?start_date=2020-08-01")
HttpRequest:ProcessRequest()
Add a header to the HTTP request. In the example we add the api token key we need to use to access the Rest API.
(string)
The name of the header field.
(string)
The value of the header field.
HttpRequest = SimLabUtils:NewHttpRequest()
HttpRequest:AddHeader("api_key", "9s8ahg9as8hasdg8kavkch")
Set the endpoint for the HTTP request. In the example we set the URI of the currency exchange API as our endpoint.
(string)
The endpoint URL for the request.
HttpRequest = SimLabUtils:NewHttpRequest()
HttpRequest:SetEndpoint("http://api.apilayer.com/exchangerates_data/timeser
ies?start_date=2020-08-01")
Set the HTTP verb (e.g., GET, POST) for the request.
(string)
The HTTP verb for the request.
HttpRequest = SimLabUtils:NewHttpRequest()
HttpRequest:SetVerb("GET")
HttpRequest:SetEndpoint("http://api.apilayer.com/exchangerates_data/timeser
ies?start_date=2020-08-01")
Returns a reference of a JSON object containing the body of the response from the endpoint. In the example we assume we did the steps for OnResponse and we received a response from the endpoint.
USimLabLuaJsonObject
:
The JSON response object.
function OnResponse()
print("Response received")
HttpResponse = HttpRequest:GetResponse()
end
Event handler for the HTTP request response. Assigns the function we want to call once we receive a reply to our HTTP request. In the example we assign the OnResponse function defined as the delegate function to call once we receive a reply after sending the HTTP request. Parameters for Add are:
(USimLabLuaHttpRequest)
: The HTTP request that triggered the response.
function OnResponse()
print("Response received")
end
HttpRequest = SimLabUtils:NewHttpRequest()
HttpRequest:SetVerb("GET")
HttpRequest:SetEndpoint("http://api.apilayer.com/exchangerates_data/timeser
ies?start_date=2020-08-01")
HttpRequest.OnResponse:Add(HttpRequest, OnResponse)
Represents a JSON Object in Lua.
Adds a new string field to the JSON structure. In the example we added a username field with its value.
JSON_Object = SimLabUtils:NewJsonObject()
JSON_Object:SetStringField("username", "SimLab123")
Adds a new number field to the JSON structure. In the example we added an age field with its value.
JSON_Object = SimLabUtils:NewJsonObject()
JSON_Object:SetNumberField("age", 21)
Adds a new boolean field to the JSON structure. In the example we added an in-stock field with its value.
JSON_Object = SimLabUtils:NewJsonObject()
JSON_Object:SetBoolField("instock", true)
Adds a new JSON object field to the JSON structure. In the example we added a set of usernames in a new field with its values.
(string)
The name of the field.
(USimLabLuaJsonObject)
The object value to set.
Usernames = SimLabUtils:NewJsonObject()
Usernames:SetStringField("username", "SimLab123")
JSON_Object = SimLabUtils:NewJsonObject()
JSON_Object:SetObjectField("Usernames", Usernames)
Set an array field in the JSON object.
(string)
The name of the field.
(Array<USimLabLuaJsonValue>)
The array value to set.
JsonArray1 = {JSONVal1, JSONVal2, JSONVal3}
local OutJSONArray1 = SimLabUtils:NewJsonValue()
OutJSONArray1:SetArray(JsonArray1)
JsonArray = {OutJSONArray1, OutJSONArray1}
local JsonArg = SimLabUtils:NewJsonObject()
JSON_Object:SetArrayField("array_arg", JsonArray)
Get a JSON Object field from the JSON object.
(string)
The name of the field.
USimLabLuaJsonObject
:
The object value of the field.
Usernames = SimLabUtils:NewJsonObject()
Usernames:SetStringField("username", "SimLab123")
JSON_Object = SimLabUtils:NewJsonObject()
JSON_Object:SetObjectField("Usernames", Usernames)
UsernamesSet = JSON_Object:GetObjectField("Usernames")
Returns an Array Referencing all JSON Objects inside the specified field.
(string)
The name of the field.
Array<USimLabLuaJsonValue>
:
The array value of the field.
local Iterate = RestAPI:GetResponse()
local IterateData = Iterate:GetArrayField("data")
Represents a Lua JSON Value in Lua.
Returns an Array of JSON Values containing the contents of the specified index from the JSON Value array.
Array<USimLabLuaJsonValue>
:
The value as an array of JSON values.
local IterateData = Iterate:GetArrayField("data")
local FirstIndex = IterateData[1]:AsArray()
Returns a JSON Object containing the contents of the specified index from the JSON Value array.
USimLabLuaJsonObject
:
The value as a JSON object.
local IterateData = Iterate:GetArrayField("data")
local FirstIndex = IterateData[1]:AsObject()
Set this value as an array of JSON values.
(Array<USimLabLuaJsonValue>)
The array of JSON values to set.
local JSONVal1 = SimLabUtils:NewJsonValue()
JSONVal1:SetObject(JsonArg11)
local JSONVal2 = SimLabUtils:NewJsonValue()
JSONVal2:SetObject(JsonArg12)
local JSONVal3 = SimLabUtils:NewJsonValue()
JSONVal3:SetObject(JsonArg13)
JsonArray1 = {JSONVal1, JSONVal2, JSONVal3}
local OutJSONArray1 = SimLabUtils:NewJsonValue()
OutJSONArray1:SetArray(JsonArray1)
Set this value as a JSON object.
(USimLabLuaJsonObject)
The JSON object to set.
local JsonArg11 = SimLabUtils:NewJsonObject()
JsonArg11:SetStringField("name", "reem1")
JsonArg11:SetStringField("gender", "Femail1")
JsonArg11:SetStringField("job_title", "Software engineer1")
local JSONVal1 = SimLabUtils:NewJsonValue()
JSONVal1:SetObject(JsonArg11)
Represents a Material in SimLab VR Viewer.
Set the color of the material.
(FLinearColor)
The new color to set.
local Nodes1 = SimLabUtils:FindNodesByName("3DBox")
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
BoxMaterial:SetMaterialColor(UE.FLinearColor(1, 0, 0))
Get the color of the material.
FLinearColor
:
The color of the material.
local Nodes1 = SimLabUtils:FindNodesByName("3DBox")
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
local Color = BoxMaterial:GetMaterialColor()
local Alpha = BoxMaterial:GetMaterialAlpha()
Color.R = math.random()
Color.B = math.random()
print(tostring(Color))
print(Alpha)
BoxMaterial:SetMaterialColor(Color)
Represents a Scene State in SimLab VR Viewer.
Extends ASimLabAnimationSequence
Get the restitution (bounce) of the material.
number
:
The restitution value of the material.
local Nodes1 = SimLabUtils:FindNodesByName("3DBox")
local Box = Nodes1[1]local BoxMaterial = Box:GetMaterial()
local Restitution = BoxMaterial:GetRestitution()
print(Restitution)
Apply the scene state.
local SceneStates = SimLabUtils:FindSceneStatesByName("Mid")
local SceneState = SceneStates[1]
SceneState:Apply()
Represents a Quiz in SimLab VR Viewer.
Activate the quiz associated with this node.
local Nodes1 = SimLabUtils:FindNodesByName("QuizButton")
Nodes1[1]:ActivateQuiz()
Represents an Animation Sequence in SimLab VR Viewer.
Get the start frame of the full animation range.
number
:
The start frame of the full animation range.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:SetPlayRange(Sequence:GetFullRangeStartFrame(), Sequence:GetFullRangeEndFrame())
print(Sequence:GetFullRangeStartFrame())
Get the end frame of the full animation range.
number
:
The end frame of the full animation range.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:SetPlayRange(Sequence:GetFullRangeStartFrame(), Sequence:GetFullRangeEndFrame())
print(Sequence:GetFullRangeEndFrame())
Set the play range of the animation sequence.
(number)
The start frame of the play range.
(number)
The end frame of the play range.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:SetPlayRange(Sequence:GetFullRangeStartFrame(), Sequence:GetFullRangeEndFrame())
Start playing the animation from the beginning.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
if Sequence:IsPlaying() then
Sequence:Stop()
else
Sequence:PlayFromStart()
end
Start playing the animation from the current frame.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:Play()
Continue playing the animation from the current frame.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:Continue()
Reverse the animation from the current frame.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:Reverse()
Reverse the animation from the end frame.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:ReverseFromEnd()
Flip the direction of the animation from the current frame.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:Flip()
Stop playing the animation.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:Stop()
Represents a Scene Node in SimLab VR Viewer.
Get the parent node of this transform node.
ASimLabTransformNode
:
The parent node.
Get the initial parent node of this transform node.
ASimLabTransformNode
:
The initial parent node.
Set the parent node of this transform node.
(ASimLabTransformNode)
The new parent node.
(string
= ""
)
Attachment rules (optional).
Get a set of children nodes of this transform node.
Set<ASimLabTransformNode>
:
A set of children nodes.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local children = Nodes[1]:GetChildrenNodes()
Get an array of ancestor nodes of this transform node.
(boolean
= false
)
Include this node in the result (optional).
Array<ASimLabTransformNode>
:
An array of ancestor nodes.
Get an attribute of this transform node by name.
(string)
The name of the attribute.
string
:
The value of the attribute.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Box
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Box" then
Box = Node
end
end
Set an attribute of this transform node by name.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Box
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Box" then
Box = Node
end
end
local BoxCopy = Box:CloneNode()
BoxCopy:SetNodeAttribute("Name", "Copy")
Check if this transform node has an attribute in a specific category by name.
boolean
:
Whether the node has the attribute in the category.
Make this node glow.
-- Highlight first airplane
FirstAirPlane = SimLabUtils:GetObjectsByAttribute("AirPlane")[1]
FirstAirPlane:GlowNode()
Stop glowing this node.
-- Stop Highlight first airplane
FirstAirPlane = SimLabUtils:GetObjectsByAttribute("AirPlane")[1]
FirstAirPlane:StopGlowNode()
Show this node.
Hide this node.
Delete this node.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Copy
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Copy" then
Copy = Node
end
end
Copy:DeleteNode()
Clone this node.
ASimLabTransformNode
:
The cloned node.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Box
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Box" then
Box = Node
end
end
local BoxCopy = Box:CloneNode()
Get the global transform of this node.
FTransform
:
The global transform.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Pyramid
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Pyramid" then
Pyramid = Node
end
end
Pyramid:AnimatedSetNodeLocalLocation(UE.FVector(0.5), 1)
Pyramid:AnimatedSetNodeLocalScale(UE.FVector(0.2), 1)
Pyramid:AnimatedSetNodeLocalRotation(UE.FRotator(0, -90 , 0), 0.3)
local WorldTransform = Pyramid:GetNodeGlobalTransform()
Get the local transform of this node.
FTransform
:
The local transform.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Pyramid
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Pyramid" then
Pyramid = Node
end
end
Pyramid:AnimatedSetNodeLocalLocation(UE.FVector(0.5), 1)
Pyramid:AnimatedSetNodeLocalScale(UE.FVector(0.2), 1)
Pyramid:AnimatedSetNodeLocalRotation(UE.FRotator(0, -90 , 0), 0.3)
local WorldTransform = Pyramid:GetNodeLocalTransform()
Get the initial global transform of this node when the scene started.
FTransform
:
The initial global transform.
Set the global transform of this node.
(FTransform)
The new global transform.
Set the relative transform of this node.
(FTransform)
The new local transform.
Get the global location of this node.
FVector
:
The global location.
Get the local location of this node.
FVector
:
The local location.
Set the global location of this node.
(FVector)
The new global location.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Box
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Box" then
Box = Node
end
end
local Player = SimLabUtils:GetFirstPlayerController()
local CameraTransform = Player:GetCameraTransform()
local CameraRotation = CameraTransform.Rotation
local CameraLocation = CameraTransform.Translation
local ForwardVector = CameraRotation:GetForwardVector()
local NewLocation = CameraLocation + ForwardVector * -3;
local BoxCopy = Box:CloneNode()
print(tostring(NewLocation))
BoxCopy:SetNodeGlobalLocation(NewLocation)
Set the local location of this node.
(FVector)
The new local location.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Pyramid
local Sphere
local Box
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Pyramid" then
Pyramid = Node
elseif AttriblueValue == "Sphere" then
Sphere = Node
elseif AttriblueValue == "Box" then
Box = Node
end
end
Box:MakeNodeGrabbable(true)
local children = Box:GetChildrenNodes()
for i,Node in ipairs(Nodes)
do
print(Node:GetNodeName())
end
Pyramid:SetNodeLocalLocation(UE.FVector(0.5))
Make this node fall to the surface.
-- Make first airplane fall to the surface
FirstAirPlane = SimLabUtils:GetObjectsByAttribute("AirPlane")[1]
FirstAirPlane:FallToSurface()
Animate setting the local location of this node.
(FVector)
The target local location.
(number
= 1.0
)
The duration of the animation in seconds (optional).
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Pyramid
local Sphere
local Box
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Pyramid" then
Pyramid = Node
elseif AttriblueValue == "Sphere" then
Sphere = Node
elseif AttriblueValue == "Box" then
Box = Node
end
end
Box:MakeNodeGrabbable(true)
local children = Box:GetChildrenNodes()
for i,Node in ipairs(Nodes)
do
print(Node:GetNodeName())
end
Pyramid:AnimatedSetNodeLocalLocation(UE.FVector(0.5), 1)
Get the global rotation of this node.
FRotator
:
The global rotation.
Get the local rotation of this node.
FRotator
:
The local rotation.
Set the global rotation of this node.
(FRotator)
The new global rotation.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Box
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Box" then
Box = Node
end
end
local Player = SimLabUtils:GetFirstPlayerController()
local CameraTransform = Player:GetCameraTransform()
local CameraRotation = CameraTransform.Rotation
local CameraLocation = CameraTransform.Translation
local ForwardVector = CameraRotation:GetForwardVector()
local NewLocation = CameraLocation + ForwardVector * -3;
local BoxCopy = Box:CloneNode()
BoxCopy:SetNodeGlobalRotation(CameraRotation:ToRotator())
Set the local rotation of this node.
(FRotator)
The new local rotation.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Pyramid
local Sphere
local Box
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Pyramid" then
Pyramid = Node
elseif AttriblueValue == "Sphere" then
Sphere = Node
elseif AttriblueValue == "Box" then
Box = Node
end
end
Box:MakeNodeGrabbable(true)
local children = Box:GetChildrenNodes()
for i,Node in ipairs(Nodes)
do
print(Node:GetNodeName())
end
Pyramid:SetNodeLocalRotation(UE.FRotator(0, -90 , 0))
Animate setting the local rotation of this node.
(FRotator)
The target local rotation.
(number
= 1.0
)
The duration of the animation in seconds (optional).
(boolean
= true
)
Whether to take the shortest path (optional).
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Pyramid
local Sphere
local Box
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Pyramid" then
Pyramid = Node
elseif AttriblueValue == "Sphere" then
Sphere = Node
elseif AttriblueValue == "Box" then
Box = Node
end
end
Box:MakeNodeGrabbable(true)
local children = Box:GetChildrenNodes()
for i,Node in ipairs(Nodes)
do
print(Node:GetNodeName())
end
Pyramid:AnimatedSetNodeLocalRotation(UE.FRotator(0, -90 , 0), 0.3)
Get the global scale of this node.
FVector
:
The global scale.
Get the local scale of this node.
FVector
:
The local scale.
Set the global scale of this node.
(FVector)
The new global scale.
Set the local scale of this node.
(FVector)
The new local scale.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Pyramid
local Sphere
local Box
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Pyramid" then
Pyramid = Node
elseif AttriblueValue == "Sphere" then
Sphere = Node
elseif AttriblueValue == "Box" then
Box = Node
end
end
Box:MakeNodeGrabbable(true)
local children = Box:GetChildrenNodes()
for i,Node in ipairs(Nodes)
do
print(Node:GetNodeName())
end
Pyramid:SetNodeLocalScale(UE.FVector(0.2))
Animate setting the local scale of this node.
(FVector)
The target local scale.
(number
= 1.0
)
The duration of the animation in seconds (optional).
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Pyramid
local Sphere
local Box
for i,Node in ipairs(Nodes)
do
local AttriblueValue = Node:GetNodeAttribute("Name")
if AttriblueValue == "Pyramid" then
Pyramid = Node
elseif AttriblueValue == "Sphere" then
Sphere = Node
elseif AttriblueValue == "Box" then
Box = Node
end
end
Box:MakeNodeGrabbable(true)
local children = Box:GetChildrenNodes()
for i,Node in ipairs(Nodes)
do
print(Node:GetNodeName())
end
Pyramid:AnimatedSetNodeLocalScale(UE.FVector(0.2), 1)
Cancel grabbing this node.
Set the grabbable sequence for this node.
(ASimLabAnimationSequence)
The grabbable sequence to set (optional).
local Nodes = SimLabUtils:FindNodesByName("Box")
local Box = Nodes[1]
local Sequneces = SimLabUtils:FindSequencesByName("Right")
local Sequence = Sequences[1]
Box:SetGrabbableSequence(Sequence)
Hide the message box on this node.
Set simulate physics to node (has to be 3D Object and enabled physics in SimLab).
(boolean)
Whether to enable simulate physics for this node.
local Nodes = SimLabUtils:FindNodesByName("Box")
local Box = Nodes[1]
Box:SetNodeSimulatePhysics(true)
Check if simulate physics is enabled for this node.
boolean
:
Whether simulate physics is enabled.
local Nodes = SimLabUtils:FindNodesByName("Box")
local Box = Nodes[1]
local IsSimulatePhysics = Box:IsNodeSimulatingPhysics()
print(tostring(IsSimulatePhysics))
Align two identical nodes to each other (useful for animations with physics illusion).
(ASimLabTransformNode)
The target node to align to.
local Nodes = SimLabUtils:FindNodesByName("Box")
local Box = Nodes[1]
local BoxCopy = Box:CloneNode()
Box:AlignNodeTo(BoxCopy)
Represents an Events Variable in SimLab VR Viewer.
Represents a Video Material in SimLab VR Viewer.
Represents a VR Camera in SimLab VR Viewer.