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.
-- Assuming that Sequence_1 exists.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
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") -- Replace "Mid" with the name of your scene state.
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") -- Replace "num" with the name of your variable.
NumVariable:SetNumberValue(num + 2)
Get the first player controller.
ASimLabController
:
The first player controller.
-- Retrieve 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.
-- Create a new JSON object
JSON_Object = SimLabUtils:NewJsonObject()
Create a new JSON value.
USimLabLuaJsonValue
:
A new JSON value.
-- Create a 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") -- Replace "3DBox" with the name of your material.
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
Set the material for an object node.
(ASimLabMaterial)
The new material to set.
-- Swap materials between two objects
local Nodes1 = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your first material.
local Box = Nodes1[1]
local Nodes2 = SimLabUtils:FindNodesByName("3DSphere") -- Replace "3DSphere" with the name of your second material.
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")
if SoundNode then
SoundNodes[1]:ToggleState()
else
print("No Sound node found")
end
Start playing the sound.
local SoundNodes = SimLabUtils:FindNodesByAttribute("SoundNode") -- Replace "SoundNode" with the name of your sound node.
local SoundNode = SoundNodes[1]
if SoundNode then
SoundNode:Play()
else
print("No Sound node found")
end
Stop the sound playback.
local SoundNodes = SimLabUtils:FindNodesByAttribute("SoundNode") -- Replace "SoundNode" with the name of your sound node.
local SoundNode = SoundNodes[1]
if SoundNode then
SoundNode:Stop()
else
print("No Sound node found")
end
Seek to a specific time in the sound playback.
(number)
The time to seek to.
local SoundNodes = SimLabUtils:FindNodesByAttribute("SoundNode")
local SoundNode = SoundNodes[1]
if SoundNode then
SoundNode:Seek(5000) -- Seek to 5 seconds
else
print("No Sound node found")
end
Play the sound for a specified duration.
(number)
The duration to play the sound.
local SoundNodes = SimLabUtils:FindNodesByAttribute("SoundNode")
local SoundNode = SoundNodes[1]
if SoundNode then
SoundNode:PlayDuration(10000) -- Play for 10 seconds
else
print("No Sound node found")
end
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
Get the attribute value with the given attribute name.
(string)
The name of the attribute to retrieve.
string
:
The attribute value.
local Controller = SimLabUtils:GetFirstPlayerController()
local AttributeValue = Controller:GetAttributeValue("Name") -- Replace "Name" with the name of your attribute.
Point the controller to a specified object node.
(ASimLabTransformNode)
The object node to point to.
local Controller = SimLabUtils:GetFirstPlayerController()
local Nodes = SimLabUtils:FindNodesByAttribute("Name") -- Replace "Name" with the name of your attribute.
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.
Get the name of the material.
string
:
The name of the material.
-- Assuming Node1 exists
local Nodes1 = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your node.
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
print(BoxMaterial:GetMaterialName())
Get the type of the material.
string
:
The type of the material.
local Nodes1 = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your node.
if Nodes1 then
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
print(BoxMaterial:GetMaterialType())
else
print("Node not found")
end
Set the color of the material.
(FLinearColor)
The new color to set.
local Nodes1 = SimLabUtils:FindNodesByName("3DBox")
if Nodes1 then
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
BoxMaterial:SetMaterialColor(UE.FLinearColor(1, 0, 0))
else
print("Node not found")
end
Get the color of the material.
FLinearColor
:
The color of the material.
-- Assuming Node exists
local Nodes1 = SimLabUtils:FindNodesByName("3DBox")
if Nodes1 then
local Box = Nodes[1]
local BoxMaterial = Box:GetMaterial()
local Color = BoxMaterial:GetMaterialColor()
local Alpha = BoxMaterial:GetMaterialAlpha()
Color.R = math.random()
Color.B = math.random()
else
print("Node not found")
end
print(tostring(Color))
print(Alpha)
BoxMaterial:SetMaterialColor(Color)
Set the alpha (transparency) of the material.
(number)
The alpha value to set.
-- Assuming Node exists
local Nodes1 = SimLabUtils:FindNodesByName("3DBox")
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
BoxMaterial:SetMaterialAlpha(0.5)
Get the alpha (transparency) of the material.
number
:
The alpha value of the material.
-- Assuming Node exists
local Nodes1 = SimLabUtils:FindNodesByName("3DBox")
if Nodes1 then
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
local Alpha = BoxMaterial:GetMaterialAlpha()
print(Alpha)
else
print("Node not found")
end
Represents a Scene State in SimLab VR Viewer.
Extends ASimLabAnimationSequence
Set Density of Physical Material Data in Material.
(number)
The density value to set.
-- Assuming Node exists
local Nodes1 = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your node.
if Nodes1 then
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
BoxMaterial:SetDensity(0.5)
else
print("Node not found")
end
Get Density of Physical Material Data in Material.
number
:
The density value of the material.
-- Assuming Node exists
local Nodes1 = SimLabUtils:FindNodesByName("3DBox")
if Nodes1
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
local Density = BoxMaterial:GetDensity()
print(Density)
Set the friction of the material.
(number)
The friction value to set.
local Nodes1 = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your node.
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
BoxMaterial:SetFriction(0.5)
Set the restitution (bounce) of the material.
(number)
The restitution value to set.
local Nodes1 = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your node.
if Nodes1 then
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
BoxMaterial:SetRestitution(0.5)
else
print("Node not found")
end
Get the restitution (bounce) of the material.
number
:
The restitution value of the material.
local Nodes1 = SimLabUtils:FindNodesByName("3DBox") -- Replace "3DBox" with the name of your node.
if Nodes1 then
local Box = Nodes1[1]
local BoxMaterial = Box:GetMaterial()
local Restitution = BoxMaterial:GetRestitution()
print(Restitution)
else
print("Node not found")
end
Apply the scene state.
local SceneStates = SimLabUtils:FindSceneStatesByName("Mid") -- Replace "Mid" with the name of your scene state.
local SceneState = SceneStates[1]
SceneState:Apply()
Represents a Quiz in SimLab VR Viewer.
Activate the quiz associated with this node.
Assuming QuizButton node exists
local Nodes1 = SimLabUtils:FindNodesByName("QuizButton")
Nodes1[1]:ActivateQuiz()
Represents an Animation Sequence in SimLab VR Viewer.
Get the name of the animation sequence.
string
:
The name of the animation sequence.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
print(Sequence:GetSequenceName())
Set whether the animation sequence is looping.
(boolean)
Whether the animation should loop.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
if Sequence:IsLooping() then -- Check if it's looping.
print("The Animation is looping")
else
Sequence:SetIsLooping(true)
end
Check if the animation sequence is looping.
boolean
:
Whether the animation is looping.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
if Sequence:IsLooping() then -- Check if it's looping.
print("The Animation is looping")
end
Set whether the animation sequence is swinging.
(boolean)
Whether the animation should swing.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
Sequence:SetIsSwinging(true)
Check if the animation sequence is swinging.
boolean
:
Whether the animation is swinging.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
print(tostring(Sequence:IsSwinging()))
Set the play rate of the animation sequence.
(number)
The new play rate.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
local Sequence = Sequences[1]
Sequence:SetPlayRate(0.5)
Get the play rate of the animation sequence.
number
:
The play rate of the animation.
-- Assuming Sequence_1 exits
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
if Sequence then
local Sequence = Sequences[1]
PlayRate = Sequence:GetPlayRate()
print(tostring(PlayRate))
else
print("Sequence not found")
end
Get the start frame of the full animation range.
number
:
The start frame of the full animation range.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
if Sequence then
local Sequence = Sequences[1]
Sequence:SetPlayRange(Sequence:GetFullRangeStartFrame(), Sequence:GetFullRangeEndFrame())
print(Sequence:GetFullRangeStartFrame())
else
print("Sequence not found")
end
Get the end frame of the full animation range.
number
:
The end frame of the full animation range.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
if Sequences then
local Sequence = Sequences[1]
local endFrame = Sequence:GetFullRangeEndFrame()
print(tostring(endFrame))
else
print("Sequence not found")
end
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") -- Replace "Sequence_1" with name of your sequence.
if Sequence then
local Sequence = Sequences[1]
local playRange = Sequence:SetPlayRange(Sequence:GetFullRangeStartFrame(), Sequence:GetFullRangeEndFrame())
print(tostring(playRange)
else
print("Sequence not found")
end
Get the start frame of the play range.
number
:
The start frame of the play range.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1") -- Replace "Sequence_1" with the name of your sequence.
if Sequence then
local Sequence = Sequences[1]
print(Sequence:GetPlayRangeStartFrame())
else
print("Sequence not found")
end
Get the end frame of the play range.
number
:
The end frame of the play range.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
if Sequence then
local Sequence = Sequences[1]
print(Sequence:GetPlayRangeEndFrame())
else
print("Sequence not found")
end
Start playing the animation from the beginning.
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
if Sequence:IsPlaying() then
Sequence:Stop()
print("Sequence Stopped")
else
Sequence:PlayFromStart()
end
Start playing the animation from the current frame.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:Play()
Continue playing the animation from the current frame.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:Continue()
Reverse the animation from the current frame.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:Reverse()
Reverse the animation from the end frame.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:ReverseFromEnd()
Flip the direction of the animation from the current frame.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:Flip()
Stop playing the animation.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
Sequence:Stop()
Check if the animation is currently playing.
boolean
:
Whether the animation is playing.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
if Sequence:IsPlaying() then
Sequence:Stop()
else
Sequence:PlayFromStart()
end
Check if the animation is currently reversing.
boolean
:
Whether the animation is reversing.
-- Assuming Sequence_1 exists
local Sequences = SimLabUtils:FindSequencesByName("Sequence_1")
local Sequence = Sequences[1]
if Sequence:IsReversing() then
Sequence:ReverseFromEnd()
print("Reversed From End")
else
Sequence:Reverse()
print("Reversed")
end
Represents a Scene Node in SimLab VR Viewer.
Get the parent node of this transform node.
ASimLabTransformNode
:
The parent node.
-- Assuming node exists
local node = SimLabUtils:FindNodesByName("node_1") -- Replace "node_1" with the name of your node.
-- Get the parent node of the current node
local parentNode = node[1]:GetParentNode()
print(tostring(parentNode))
Get the initial parent node of this transform node.
ASimLabTransformNode
:
The initial parent node.
-- Assuming node exists
local node = SimLabUtils:FindNodesByName("node_1")
-- Get the parent node of the current node
local initialParentNode = node[1]:GetInitialParentNode()
print(tostring(initialParentNode))
Set the parent node of this transform node.
(ASimLabTransformNode)
The new parent node.
(string
= ""
)
Attachment rules (optional).
-- Assuming node exists
local childNode = SimLabUtils:FindNodesByName("node_1")
local parentNode = childNode[1]:SetParentNode(parentNode)
print(tostring(parentNode))
Reset this node to its initial parent node.
(string
= ""
)
Attachment rules (optional).
-- Assuming node exists
local node = SimLabUtils:FindNodesByName("node_1")
-- Reset parent node to initial
local parentNode = node:ResetToInitialParentNode()
print(tostring(parentNode))
Get a set of children nodes of this transform node.
Set<ASimLabTransformNode>
:
A set of children nodes.
-- Assuming node exists
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.
-- set to false if you don't want to include the node itself
local bIncludingMe =True
local node = SimLabUtils:FindNodesByName("node_1") -- Replace "node_1" with the name of your node.
local ancestors = node[1]:GetAncestorNodes(bIncludingMe)
print(tostring(ancestors))
Get an attribute of this transform node by name.
(string)
The name of the attribute.
string
:
The value of the attribute.
-- Assuming node Box exists
local Nodes = SimLabUtils:FindNodesByName("Box")
local Box = Nodes[1]
if Box:NodeHasAttribute() then
local AttriblueValue = Box:GetNodeAttribute("Name")
else
print("Attribute Not Found")
end
Get an attribute from a specific category of this transform node by name.
string
:
The value of the attribute.
-- Assuming node attribute exists
local Nodes = SimLabUtils:FindNodesByAttribute("Name") -- Replace "Name" with the name of your node.
local Node = Nodes[1]
local AttriblueValue = Node:GetNodeAttributeFromCategory("Name")
Set an attribute of this transform node by name.
-- Assuming node exists
local Nodes = SimLabUtils:FindNodesByName("Node_1")
local attributeName = "Color"
local attributeValue = "Red"
BoxCopy:SetNodeAttribute("Color", "Red")
print(tostring(Nodes[1]:NodeHasAttribute("Color"))
Set an attribute in a specific category of this transform node by name.
(string)
The name of the attribute.
(string)
The value to set.
(string)
The category of the attribute.
local Nodes = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your attribute.
local attributeName = "Color"
local attributeValue = "Red"
local Category = "Appearance"
--Set Attribute to the Node
local AttributeNew = Nodes[1]:SetNodeAttributeInCategory(attributeName, attributeValue, Category)
-- Check if the node has the specified attribute
local hasAttribute = Nodes[1]:NodeHasAttribute("Color")
print(tostring(hasAttribute))
Check if this transform node has a specific attribute by name.
(string)
The name of the attribute.
boolean
:
Whether the node has the attribute.
local node = SimLabUtils:FindNodesByName("Name") -- Replace "Name" with the name of your node.
-- Check if the node has the specified attribute
local hasAttribute = node[1]:NodeHasAttribute(attributeName)
print(tostring(hasAttribute))
Check if this transform node has an attribute in a specific category by name.
boolean
:
Whether the node has the attribute in the category.
-- Assuming node attriblue exists
local nodes = SimLabUtils:FindNodesByAttribute("Name")
local attributeName = "Color"
local attributeCategory = "Visuals"
local hasAttributeInCategory = nodes[1]:NodeHasAttributeInCategory(attributeName, attributeCategory)
print(tostring(hasAttributeInCategory))
Set the glow state of this node.
(boolean)
Whether to set the node as glowing.
-- Assuming node_1 exists
local node = SimLabUtils:FindNodesByName("node_1") -- Replace "node_1" with the name of your node.
-- Set the glow state of the node (true to enable glow, false to disable)
node[1]:SetNodeGlowState(true)
print("Node glow state set to enabled.")
Make this node glow.
-- Highlight first airplane
FirstAirPlane = SimLabUtils:GetObjectsByAttribute("AirPlane")
if FirstAirPlane then
--Make Node Glow
FirstAirPlane[1]:GlowNode()
else
print("Node Has Not Found")
end
Stop glowing this node.
-- Stop Highlight first airplane
FirstAirPlane = SimLabUtils:GetObjectsByAttribute("AirPlane")
if FirstAirPlane[1]:GlowNode() then
FirstAirPlane[1]:StopGlowNode()
print("The Node Stopped Glowing")
else
print("Node is not Glowing)
end
Check if this node is currently glowing.
boolean
:
Whether the node is glowing.
local node = SimLabUtils:FindNodesByName("node_1") -- Replace "node_1" with the name of your node.
-- Check if the node is currently glowing
local isGlowing = node[1]:IsNodeGlowing()
print(tostring(isGlowing))
Set the visibility state of this node.
(boolean)
Whether to set the node as visible.
-- Hide first airplane
FirstAirPlane = SimLabUtils:GetObjectsByAttribute("AirPlane")
if FirstAirPlane then
FirstAirPlane[1]:SetNodeVisibility(false)
else
print("Node Not Found")
end
Check if this node is currently visible.
boolean
:
Whether the node is visible.
local node = SimLabUtils:FindNodesByName("Box") -- Replace "Box" with the name of your node.
-- Check if the node is currently visible
local isVisible = node[1]:IsNodeVisible()
print("Is the node visible? " .. tostring(isVisible))
Show this node.
local node = SimLabUtils:FindNodesByName("node_1") -- Replace "node_1" with the name of your node.
if node then
node[1]:ShowNode()
print("Node is now visible.")
else
print("Node Not Found")
end
Hide this node.
local node = SimLabUtils:FindNodesByName("node_1") -- Replace "node_1" with the name of your node.
if node then
node[1]:HideNode()
print("Node is now hidden.")
else
print("Node Not Found.")
end
Delete this node.
local Nodes = SimLabUtils:FindNodesByName("Name") -- Replace "Name" with the name of your node.
if Nodes then
Nodes[1]:DeleteNode()
print("Node has been deleted.")
else
print("Node Not Found.")
end
Make Instance of this node.
ASimLabTransformNode
:
The new instance node.
-- Assuming Node_1 exists
local Nodes = SimLabUtils:FindNodesByName("Node_1") -- Replace "Node_1" with the name of your node.
local Node = Nodes[1]
local NodeCopy = Node:MakeNodeInstance()
Make copy of this node.
ASimLabTransformNode
:
The new copy node.
-- Assuming Node_1 exists
local Nodes = SimLabUtils:FindNodesByName("Node_1") -- Replace "Node_1" with the name of your node.
local Node = Nodes[1]
local NodeCopy = Node:MakeNodeCopy()
Get the global transform of this node.
FTransform
:
The global transform.
local Nodes = SimLabUtils:FindNodesByAttribute("Name") -- Replace "Name" with the name of your attribute.
local Pyramid = Nodes[1]
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") -- Replace "Name" with the name of your attribute.
local Pyramid =Nodes[1]
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.
-- Assuming node name is "node_1"
local node = SimLabUtils:FindNodesByName("node_1")
-- Get the initial global transform of the node
local initialGlobalTransform = node[1]:GetInitialGlobalTransform()
-- Print the initial global transform matrix
print(tostring(initialGlobalTransform))
Set the global transform of this node.
(FTransform)
The new global transform.
local node = SimLabUtils:FindNodesByName("Box")
-- Get the initial global transform of the node
local nodeTransform = node[1]:GetInitialGlobalTransform()
node[1]:SetNodeGlobalTransform(nodeTransform)
print("Node's global transform has been set.")
Set the relative transform of this node.
(FTransform)
The new local transform.
local node = SimLabUtils:FindNodesByName("node_1")
-- Get the local transformation of the node
local WorldTransform = node[1]:GetNodeLocalTransform()
-- Set node transformation
node[1]:SetNodeLocalTransform(transformMatrix)
-- Print confirmation
print("Node's global transform has been set.")
Animate setting the global transform of this node.
(FTransform)
The target global transform.
(number
= 1.0
)
The duration of the animation in seconds (optional).
-- Assuming node exists
local node = SimLabUtils:FindNodesByName("Box")
-- Create a transformation matrix for the target transform
local targetTransform = node[1]:SetNodeGlobalTransform()
-- Set the animation duration in seconds
local duration = 3.0 -- 3 seconds for the transformation to complete
-- Apply the animated global transform to the node
node[1]:AnimatedSetNodeGlobalTransform(targetTransform, duration)
-- Print confirmation
print("Node's global transform is animating over " .. duration .. " seconds.")
Animate setting the local transform of this node.
(FTransform)
The target local transform.
(number
= 1.0
)
The duration of the animation in seconds (optional).
-- Create a new node object
local node = SimLabUtils:FindNodesByName("Box")
-- Create a transformation matrix for the target transform
local targetTransform = node[1]:SetNodeGlobalTransform()
-- Set the animation duration in seconds
local duration = 3.0 -- 3 seconds for the transformation to complete
-- Apply the animated global transform to the node
node[1]:AnimatedSetNodeLocalTransform(targetTransform, duration)
-- Print confirmation
print("Node's global transform is animating over " .. duration .. " seconds.")
Get the global location of this node.
FVector
:
The global location.
local node = SimLabUtils:FindNodesByName("node_1")
-- Get the global location of the node
local globalLocation = node[1]:GetNodeGlobalLocation()
-- Print the global location (x, y, z)
print("Node's global location: " .. tostring(globalLocation))
Get the local location of this node.
FVector
:
The local location.
local node = SimLabUtils:FindNodesByName("node_1")
-- Get the local location of the node
local localLocation = node[1]:GetNodeLocalLocation()
-- Print the local location (x, y, z)
print("Node's local location: " .. tostring(localLocation))
Set the global location of this node.
(FVector)
The new global location.
local Nodes = SimLabUtils:FindNodesByAttribute("Name")
local Box = Nodes[1]
local Player = SimLabUtils:GetFirstPlayerController()
-- Assuming there is a camera in the scene
local CameraTransform = Player:GetCameraTransform()
local CameraRotation = CameraTransform.Rotation
local CameraLocation = CameraTransform.Translation
local ForwardVector = CameraRotation:GetForwardVector()
local NewLocation = CameraLocation + ForwardVector * -3;
local BoxCopy = Box:MakeNodeCopy()
print(tostring(NewLocation))
BoxCopy:SetNodeGlobalLocation(NewLocation)
Set the local location of this node.
(FVector)
The new local location.
local Nodes = SimLabUtils:FindNodesByName("Box")
if Nodes then
local Box = Nodes[1]
local locallocation = Box:SetNodeLocalLocation(UE.FVector(0.5))
print(tostring(locallocation))
else
print("Node Not Found")
end
Make this node fall to the surface.
-- Make first airplane fall to the surface
FirstAirPlane = SimLabUtils:GetObjectsByAttribute("AirPlane")
FirstAirPlane[1]:FallToSurface()
Animate making this node fall to the surface.
(number
= 1.0
)
The duration of the animation in seconds (optional).
-- Assuming Node_1 exists
local node = SimLabUtils:FindNodesByName("node_1")
-- Set the duration for the fall animation
local duration = 2.0 -- Fall over 2 seconds
-- Apply the animated fall to the surface
node[1]:AnimatedFallToSurface(duration)
-- Print confirmation
print("Node is animating a fall to the surface over " .. duration .. " seconds.")
Animate setting the global location of this node.
(FVector)
The target global location.
(number
= 1.0
)
The duration of the animation in seconds (optional).
-- Create a new node object
local node = SimLabUtils:FindNodesByName("Box")
-- Create a transformation matrix for the target transform
local targetTransform = node[1]:SetNodeGlobalTransform()
-- Set the animation duration in seconds
local duration = 3.0 -- 3 seconds for the transformation to complete
-- Apply the animated global location to the node
node[1]:AnimatedSetNodeGlobalLocation(targetTransform, duration)
-- Print confirmation
print("Node's global transform is animating over " .. duration .. " seconds.")
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.
local node = SimLabUtils:FindNodesByName("Box")
-- Get the global location of the node
local globalLocation = node[1]:GetNodeGlobalRotation()
-- Print the global Rotation (x, y, z)
print("Node's global location: " .. tostring(globalLocation))
Get the local rotation of this node.
FRotator
:
The local rotation.
-- Assuming node Box exists
local node = SimLabUtils:FindNodesByName("Box")
-- Get the global location of the node
local globalLocation = node[1]:GetNodeLocalRotation()
-- Print the global Rotation (x, y, z)
print("Node's global location: " .. tostring(globalLocation))
Set the global rotation of this node.
(FRotator)
The new global rotation.
local Nodes = SimLabUtils:FindNodesByAttribute("Name") -- Replace "Name" with the name of your attribute
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()
-- Assuming there is a camera in the scene
local CameraTransform = Player:GetCameraTransform()
local CameraRotation = CameraTransform.Rotation
local CameraLocation = CameraTransform.Translation
local ForwardVector = CameraRotation:GetForwardVector()
local NewLocation = CameraLocation + ForwardVector * -3;
local BoxCopy = Box:MakeNodeCopy()
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 global rotation of this node.
(FRotator)
The target global 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 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()
-- Assuming there is a camera in the scene
local CameraTransform = Player:GetCameraTransform()
local CameraRotation = CameraTransform.Rotation
local CameraLocation = CameraTransform.Translation
local ForwardVector = CameraRotation:GetForwardVector()
local NewLocation = CameraLocation + ForwardVector * -3;
local BoxCopy = Box:MakeNodeInstance()
BoxCopy:AnimatedSetNodeGlobalRotation(CameraRotation:ToRotator())
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.
local node = SimLabUtils:FindNodesByName("Box")
-- Get the global location of the node
local globalLocation = node[1]:GetNodeGlobalScale()
-- Print the global location (x, y, z)
print("Node's global location: " .. tostring(globalLocation))
Get the local scale of this node.
FVector
:
The local scale.
local node = SimLabUtils:FindNodesByName("Box")
-- Get the local location of the node
local localLocation = node[1]:GetNodeLocalScale()
-- Print the local location (x, y, z)
print("Node's local location: " .. tostring(localLocation))
Set the global scale of this node.
(FVector)
The new global 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:SetNodeGlobalScale(UE.FVector(0.2))
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 global scale of this node.
(FVector)
The target global 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:AnimatedSetNodeGlobalScale(UE.FVector(0.2), 1)
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.
local node = SimLabUtils:FindNodesByName("Box")
if node[1]:CancelNodeGrab() then
print("The grab action for the node has been canceled.")
end
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)
Show a message box on this node.
local Nodes = SimLabUtils:FindNodesByName("Box")
title = "Warning"
body = "Are you sure you want to proceed?"
Nodes[1]:ShowMessageBox(title, body)
Check if a message box is currently shown on this node.
boolean
:
Whether a message box is shown.
local Nodes = SimLabUtils:FindNodesByName("Box")
if Nodes[1]:IsMessageBoxShown() then
print("A message box is currently being displayed.")
else
print("No message box is shown.")
end
Hide the message box on this node.
local Nodes = SimLabUtils:FindNodesByName("Box")
if Nodes[1]:IsMessageBoxShown() then
Nodes[1]:HideMessageBox()
else
print("No message box is shown.")
end
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:MakeNodeCopy()
Box:AlignNodeTo(BoxCopy)
Represents an Events Variable in SimLab VR Viewer.
The name of the variable.
Type: string
local myVariable = 10
local _anotherVar = "Hello"
The type name of the variable.
Type: string
local myVar = 42
print(type(myVar)) -- Output: "number"
Set the variable's value to a string.
(string)
The new string value to set.
local node = SimLabUtils:FindNodesByName("node_1")
if node then
local newStringValue = "New String Value"
node[1]:SetStringValue(newStringValue)
print("Node's string value has been set to: " .. newStringValue)
else
print("Node not found.")
end
Set the variable's value to a float.
(number)
The new float value to set.
local node = SimLabUtils:FindNodesByName("node_1")
if node then
local newFloatValue = 3.14159
node[1]:SetNumberValue(newFloatValue)
print("Node's float value has been set to: " .. tostring(newFloatValue))
else
print("Node not found.")
end
Set the variable's value to an integer.
(number)
The new integer value to set.
local node = SimLabUtils:FindNodesByName("Box")
local variableName = "SomeVariable" -- Replace "SomeVariable" with the name of your variable.
local newValue = 42
node[1]:SetIntegerValue(variableName, newValue)
Set the variable's value to the current time.
Represents a Video Material in SimLab VR Viewer.
Toggle the playback state of the video.
local node = SimLabUtils:FindNodesByName("node_1")
if node then
node[1]:ToggleState() -- Call the method to toggle the state
print("Node's state has been toggled.")
else
print("Node not found.")
end
Start playing the video.
local VideoNode = SimLabUtils:FindNodesByAttribute("VideoNode")
VideoNode[1]:Play()
Stop the video playback.
local VideoNode = SimLabUtils:FindNodesByAttribute("VideoNode") -- Replace "VideoNodes" with the name of your video node.
VideoNode[1]:Stop()
Play the video for a specified duration.
(number)
The duration to play the video.
local VideoNodes = SimLabUtils:FindNodesByAttribute("VideoNodes") -- Replace "VideoNodes" with the name of your video node.
VideoNodes[1]:PlayDuration(10000) -- Play for 10 seconds
Represents a VR Camera in SimLab VR Viewer.
Check if orientation is applied when teleporting to the camera.
boolean
:
Whether orientation is applied when teleporting.
-- Assuming node_1 exists
local node = SimLabUtils:FindNodesByName("node_1")
if node then
local applyOrientation = node[1]:IsApplyOrientation() -- Check if orientation is applied
if applyOrientation then
print("Orientation is applied when teleporting to the camera.")
else
print("Orientation is not applied when teleporting to the camera.")
end
else
print("Node not found.")
end
Get the teleport location of the camera.
FVector
:
The teleport location.
-- Assuming node_1 exists
local node = SimLabUtils:FindNodesByName("node_1")
if node then
local teleportLocation = node[1]:GetTeleportLocation() -- Get the teleport location
print("Teleport location of the camera is:")
print("X: " .. teleportLocation.x)
print("Y: " .. teleportLocation.y)
print("Z: " .. teleportLocation.z)
else
print("Node not found.")
end
Get the teleport rotation of the camera.
FRotator
:
The teleport rotation.
-- Assuming node_1 exists
local node = SimLabUtils:FindNodesByName("node_1")
if node then
local teleportRotation = node[1]:GetTeleportRotation() -- Get the teleport rotation
print("Teleport rotation of the camera is:")
print("Pitch: " .. teleportRotation.pitch)
print("Yaw: " .. teleportRotation.yaw)
print("Roll: " .. teleportRotation.roll)
else
print("Node not found.")
end