Skip to content

Environment

Inherits Instance

Environment is the primary object intended for storing active objects in the place.

Static Class

This object is a static class. It can be accessed by using its name as a keyword.

Additionally, it cannot be created in the creator menu or with Instance.New().

Not newable

This object cannot be created by scripts using Instance.New().

Properties

CurrentCamera : Camera

Determines the current camera which player is using to view

Gravity : Vector3

The direction and strength of gravity in the world.

PartDestroyHeight : number

The height at which unanchored parts are destroyed when they fall below it.

AutoGenerateNavMesh : boolean

Determines whether or not to automatically build a navigation mesh for NPC pathfinding. This property is disabled by default so there are no performance issues with larger maps.

Methods

Raycast → RayResult

Parameters

origin [ Vector3 ]

direction [ Vector3 ]

maxDistance [ number? ]

ignoreList [ table? ]

Casts a ray from origin with a specified direction and returns a RayResult for the first hit object.

RaycastAll → table

Parameters

origin [ Vector3 ]

direction [ Vector3 ]

maxDistance [ number? ]

ignoreList [ table? ]

Casts a ray from origin with a specified direction and returns a RayResult array for all hit objects.

OverlapSphere → table

Parameters

origin [ Vector3 ]

radius [ number ]

ignoreList [ table? ]

Returns a list of instances intersecting with the sphere in the given position and radius.

OverlapBox → table

Parameters

pos [ Vector3 ]

size [ Vector3 ]

rot [ Vector3 ]

ignoreList [ table? ]

Returns a list of instances intersecting with the box in the given position, size and rotation.

RebuildNavMesh → nil

Parameters: ``

Rebuilds the navigation mesh which determines the empty space where NPCs can pathfind in.

GetPointOnNavMesh → Vector3

Parameters: toPoint [ Vector3 ]

Returns a point on the navigation mesh at the given position.