World
The global world
variable is always available within the app scripting runtime.
.networkId
: String
A unique ID for the current server or client.
.isServer
: Boolean
Whether the script is currently executing on the server.
.isClient
: Boolean
Whether the script is currently executing on the client.
.add(node)
Adds a node into world-space, outside of the apps local hierarchy.
.remove(node)
Removes a node from world-space, outside of the apps local hierarchy.
.attach(node)
Adds a node into world-space, maintaining its current world transform.
.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)
Unsubscribes from world events.
.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)
Creates a bitmask to be used in world.raycast()
.
Currently the only groups available are environment
and player
.
.getPlayer(playerId)
: Player
Returns a player. If no playerId
is provided it returns the local player.
.getPlayers()
: […Player]
Returns an array of all players.