Skip to main content

Scene

Client Server

Methods

number GetTime()

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.transform.pos = self.transform.pos + move * speed * Scene:GetDeltaTime()
end

number GetDebugTime()

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)

Camera GetActiveCamera()

nil SetActiveCamera(Camera cam)

string AddNewScriptFile(string scriptName, Object forObject)

VoxelDB? GetVoxelDB(string db)

Hit[] TraceRay(table params)

Vec3|Vec3[] ConvertWcToDc(VoxelRenderer vr, Vec3|Vec3[] wcPos)

Vec3|Vec3[] ConvertDcToWc(VoxelRenderer vr, Vec3|Vec3[] dcPos)

boolean IsNameValid(string name)

string MakeNameValid(string name)

table GetLogCounters()

nil ResetLogCountersDif()

boolean UpdatePrefab(Object obj)

boolean ResetPrefab(Object obj)

nil ResetAllPrefabs()

nil UnpackPrefab(Object obj)

nil RebuildLighting()

nil CreateLighting(string type, string algo)

boolean GetProfileScriptsUpdate()

nil SetProfileScriptsUpdate(boolean value)

table GetSimpleStats()

table GetVDRStats()

table GetScriptsProfiling()

Properties

integer voxelDataResourceTemplateSizeThreshold

integer VoxelDataResourceTemplateSizeThreshold

boolean SimulationPaused

number SimulationSpeed

number Gravity