Work with Assembly Nodes

Using Lua to interact with Assembly nodes

This node type describes position, rotation and scale properties, as well as constraint information.


Property Name





Enabled or disabled.



The raw transformation matrix.



Type of constraint. See constraint type table below.



A signed integer representing the collision layer of this assembly. Higher values take priority over lower values. I.e. if multiple ray intersections are returned from the collision system, then the one associated with an assembly with the highest layer value will be used.

Constraint Types

Type String



No constraint is applied


No changes to the local transform are allowed


Defers transform changes to the parent assembly. Moving this assembly moves the parent instead.


Constraints the assembly according to the parameters of the TransformLimits child node (which might need creating if it does not exist)


Direct Property Access

-- Drag/Drop section BEGINS - Do not edit between BEGINS and ENDS.
local King_white = __Script.dragdrop.King_white
-- Drag/Drop section ENDS

-- toggle the Enabled state of the Assembly
King_white.Enabled = not King_white.Enabled

-- get the local transform values of the king
local xform = King_white.Transform

-- add 0.01 to the Y value of the position - this immediately applies to the assembly
xform.Position.Y = xform.Position.Y + 0.01

Working with Transforms

The transform property provides a special set of objects that allow direct control over the assembly, as opposed to having to read a transform out, modify it, then write it back.

local test = vrTreeRoot():find("root/Scenes/Cube")

-- Set position of an assembly.
test.Transform.Position = vrVec3(0, 0.1, 0)
test.Transform.Position = {0, 0.1, 0}

-- Set the rotation of an assembly.
test.Transform.Rotation = vrVec3(90, 0, 180)
test.Transform.Rotation = {90, 0, 180}

-- Set the scale
test.Transform.Scale = vrVec3(2, 2, 2)
test.Transform.Scale = {2, 2, 2}

-- Set the x component of the nodes position.
test.Transform.Position.X = 10

-- Set the x component of the nodes world position.
test.WorldTransform.Position.X = 20

-- Create a new transform
local newTransform = vrMat4()
newTransform.Position = {10, 10, 10}

-- Assign a new transform to a node
test.Transform = newTransform
Care should be taken when assigning variables from transforms, because, with the exception of individual elements (e.g Transform.Position.X), they are references to the matrix rather than a copy.

-- If you assign any part of a nodes transform to a variable, it is a reference.
local newNode = vrCreateNode("Assembly", "newNode", test)
local pos = newNode.Transform.Position
local xPos = newNode.Transform.Position.X

-- pos is now a reference to newNode.Transform.Position
pos.X = 5
-- newNode.Transform.Position.x == 5

-- xPos is not a reference to newNode.Transform.Position.X since it is just a number, it is copied.
xPos = 10
-- newNode.Transform.Position.x == 5

-- pos is only valid as long as the node exists.
pos.X = 10 -- ERROR (only if the history manager is disabled, otherwise the node will still exist in the recycling bin)

-- xPos can still be assigned to since it was copied.
xPos = 20
Scripts can also work directly with a matrix before setting the Transform property

-- Construct matrix transformations
local newMat = vrMat4()
newMat = vrMatRotateEulerX(newMat, 10)
newMat = vrMatTranslate(newMat, {10, 10, 10})
newMat = vrMatScale(newMat, {2, 2, 2})
Scripts can multiply, add and subtract matrices from one another, as well as transform vectors using the multiplication operator

local newMat = vrMat4()
newMat.Position = {100, 0, 0}
local otherMat = vrMat4()
otherMat.Rotation = {10, 20, 30}

local combinedMat = newMat * otherMat
local transformedVec = combinedMat * vrVec3(0, 0, 0)

No Results.

Getting StartedArchitectureBest PracticesHow ToAdvanced TopicsChangelogvrtree_cppCoreForeign Function InterfaceMetanodesMigrationsObserversPropertiesTreeUtilitiesAPI DefinitionsVR ExchangePluginsLua API