Skip to main content

Scene

Client Server

Methods

number GetTime()

Simulation time in seconds; use this instead of the sandboxed os.time.

number GetDeltaTime()

Time passed since the last Update() call. Since time between updates is not constant use this to adjust changes such as movement according to the amount of time that has passed

function self:Update()
local speed = 10
local move = Vec3.right
--remember to multiply by delta time, since the time passed between each Update() is not constant
self.obj.pos = self.obj.pos + move * speed * Scene:GetDeltaTime()
end

number GetDebugTime()

High-resolution wall-clock time in seconds, for measuring real-time differences.

integer GetCurrentFrame()

string GetProcessState()

What is currently being processed i.e Start, Update, LateUpdate etc.

Object CreateObject(string? name, Object? parentObj, boolean? save, boolean? selectInEditor)

Create an object on server or client. The object is not automatically synced to clients unless its set to. For naming we recommend to:

  • Use capital case
  • Use spaces between words
  • If the object only holds a script component, name the object after the script
  • Avoid creating multiple objects with the same name (i.e. by numbering them)
  • If the object somehow belongs to a player include the user ID in the name
local ob = Scene:CreateObject("Player Controller 1")

Also see Scene:MakeNameValid

Object CreateObject(string name, boolean save, boolean selectInEditor)

nil DestroyObject(Object obj)

Flags the object for deletion. The object will not actually be destroyed until the next frame.

Object[] GetObjectsByName(string name)

Object GetObjectByName(string name)

Object GetObjectById(string id)

Object[] GetRootObjects()

Object[] GetAllObjects()

Object CloneObject(Object obj)

Object CloneObject(Object obj, Object intoObj)

Object CloneObject(Object obj, string name)

nil MoveObject(Object obj, Object newParentObj)

nil MoveObjectAfter(Object obj, Object siblingObj)

nil MoveObjectBefore(Object obj, Object siblingObj)

nil MoveObjectToRoot(Object obj)

boolean CanMoveObject(Object obj, Object newParentObj)

Material? CreateMaterial(string path)

Gets the shared Material the renderer actually draws with (the cached instance, not a copy) — use it to drive live shader uniforms via Material:SetProperty.

Camera GetActiveCamera()

Returns the currently active (rendering) camera.

nil SetActiveCamera(Camera cam)

Makes the given camera the active view.

string AddNewScriptFile(string scriptName, Object forObject)

VoxelDB? GetVoxelDB(string db)

boolean IsNameValid(string name)

string MakeNameValid(string name)

table GetLogCounters()

nil ResetLogCountersDif()

boolean ResetPrefab(Object obj)

nil ResetAllPrefabs()

nil UnpackPrefab(Object obj)

nil RebuildLighting()

nil CreateLighting(string type, string algo)

boolean GetProfileScriptsUpdate()

nil SetProfileScriptsUpdate(boolean value)

Enables or disables collection of the per-script Update timings read by GetScriptsProfiling. Toggling it off only stops collection — the accumulated avg/max survive until cleared by Server:LuaReset().

table GetSimpleStats()

table GetVDRStats()

table GetScriptsProfiling()

Returns an array of per-script-type rows (summed across all instances of that script), each row being {name, time, avg, max, cnt}:

FieldMeaning
nameScript type name
timeTime in the last frame (µs)
avgRunning average per frame (µs) — use this for stable readings
maxWorst single frame (µs)
cntNumber of live instances of this script

All times are in microseconds (may come back as comma-formatted strings — parse with tonumber((tostring(v):gsub(",","")))). Collection must first be enabled with SetProfileScriptsUpdate(true), otherwise the rows stay empty/stale. Only time spent inside Update/LateUpdate is counted — work in RPC handlers, event listeners, and Attach/Start is not attributed here.

Properties

integer voxelDataResourceTemplateSizeThreshold

boolean simulationPaused

number simulationSpeed

number gravity