World
The global world
variable is always available within the app scripting runtime.
.networkId
: String
Section titled “.networkId: String”A unique ID for the current server or client.
.isServer
: Boolean
Section titled “.isServer: Boolean”Whether the script is currently executing on the server.
.isClient
: Boolean
Section titled “.isClient: Boolean”Whether the script is currently executing on the client.
.add(node)
Section titled “.add(node)”Adds a node into world-space, outside of the apps local hierarchy.
.remove(node)
Section titled “.remove(node)”Removes a node from world-space, outside of the apps local hierarchy.
.attach(node)
Section titled “.attach(node)”Adds a node into world-space, maintaining its current world transform.
.on(event, callback)
Section titled “.on(event, callback)”Subscribes to world events.
Currently only enter
and leave
are available which let you know when a player enters or leaves the world.
.off(event, callback)
Section titled “.off(event, callback)”Unsubscribes from world events.
.raycast(origin: Vector3, direction: Vector3, maxDistance: ?Number, layerMask: ?Number)
Section titled “.raycast(origin: Vector3, direction: Vector3, maxDistance: ?Number, layerMask: ?Number)”Raycasts the physics scene.
If maxDistance
is not specified, max distance is infinite.
If layerMask
is not specified, it will hit anything.
.createLayerMask(...groups)
Section titled “.createLayerMask(...groups)”Creates a bitmask to be used in world.raycast()
.
Currently the only groups available are environment
and player
.
.getPlayer(playerId)
: Player
Section titled “.getPlayer(playerId): Player”Returns a player. If no playerId
is provided it returns the local player.
.getPlayers()
: […Player]
Section titled “.getPlayers(): […Player]”Returns an array of all players.