WorldRoot

WorldRoot : Instance

Overview

A WorldRoot is a class used for detecting or simulating Objects in 3D space

Properties

Methods

Blockcast

Moves a box-shaped region defined by a given position (CFrame) and size (Extents) into a specified Direction, detects any objects along its path, and returns the result as a RaycastResult object. It works like Raycast, but can detect a broader region of Objects as it detects collision in a box shape instead of a ray shape.

Parameters

CFrame InCFrame

The coordinate frame representing a box’s initial position and rotation.

Vector3 InExtents

A vector defining the size (width, length, height) of a box.

Vector3 InDirection

A vector representing the box’s movement direction; its length (size) also determines the detectable distance.

RaycastParams InRaycastParams

A settings object that configures object detection conditions. Use RaycastParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.

Return

RaycastResult

A result object containing information about the first object the box collided with along its path. Returns nil if no collision occurs.

Code Samples

Capsulecast

Moves a capsule-shaped region defined by a given position (CFrame), Radius, and Height into a specified Direction, detects any objects along its path, and returns the result as a RaycastResult object. Ideal for predicting character movement paths or collisions, as it detects collisions using capsule shape which resembles a character's form.

Parameters

CFrame InCFrame

The coordinate frame representing the initial position and rotation of a capsule.

number InRadius

The radius of a capsule.

number InHeight

The height of a capsule.

Vector3 InDirection

A vector representing the capsule’s movement direction; its length (size) also determines the detectable distance.

RaycastParams InRaycastParams

A settings object that configures object detection conditions. Use RaycastParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.

Return

RaycastResult

A result object containing information about the first object the capsule collided with along its path. Returns nil if no collision occurs.

Code Samples

DrawRay

This method displays a ray of a specified color on the screen based on a given origin and direction for visual representation.

This is mainly used for debugging and is helpful for visually identifying the direction and destination of a Raycast.

Parameters

Vector3 InOrigin

The starting point from which the ray is cast.

Vector3 InDirection

This vector defines the direction of the ray. The length (magnitude) of this vector also determines how far the ray can detect Objects.

Color3 InColor

The color of the ray.

number InThickness

The width of the ray.

number InLifeTime

The duration (in seconds) that the ray persists in the world.

Return

void

Code Samples

GetPartBoundsInBox

Searches for and returns an array of parts that overlap with a box-shaped region defined by a given Center and Size. Use OverlapParams to fine-tune filtering conditions and detection scope.

Parameters

CFrame InCenter

The center coordinate of the region to be detected.

Vector3 InSize

The width, height, and depth of the box-shaped detection region.

OverlapParams InOverlapParams

A settings object that configures object detection conditions. Use OverlapParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.

Return

array

An array of the objects detected within the box-shaped region.

Code Samples

GetPartBoundsInSphere

Searches for and returns an array of parts that overlap with a sphere-shaped region defined by a given Center and Radius. It is useful for proximity check or Area-of-Effect detection.

Parameters

CFrame InCenter

The center coordinate of the sphere-shaped region to be detected.

number InRadius

The radius of a sphere.

OverlapParams InOverlapParams

A settings object that configures object detection conditions. Use OverlapParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.

Return

array

An array of the objects detected within the sphere-shaped region.

Code Samples

GetPartsInPart

Searches for and returns an array of all parts that overlap (collide) with a specified BasePart. Use OverlapParams to fine-tune filtering conditions, such as including or excluding specific objects.

Parameters

BasePart InBasePart

The part used as the reference for collision detection.

OverlapParams InOverlapParams

A settings object that configures object detection conditions. Use OverlapParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.

Return

array

An array of the objects detected within the part region.

Code Samples

PredictProjectilePathByObject

Calculates and returns the predicted trajectory of a projectile based on object query parameters.

Parameters

PredictProjectilePathParams PredictParams

An object containing parameters required for trajectory prediction, including the projectile's starting position, velocity, and gravity.

CollisionObjectQueryParams InObjectParams

An object specifying which object types should be detected for collisions. Allows setting specific object types as collision targets.

Return

PredictProjectilePathResult

A result object containing information about the first object the projectile collided with along its trajectory.

Code Samples

Raycast

Casts an invisible ray based on a given origin and direction to detect objects along its path, and returns the result as a RaycastResult object. You can use a RaycastParams object to define specific targets or conditions for detection if needed. If omitted, the default settings apply, and all parts become detectable.

Parameters

Vector3 InOrigin

The origin point from which the ray is cast.

Vector3 InDirection

A vector representing the ray’s direction; its length (size) also determines the detectable distance.

RaycastParams InRaycastParams

A settings object that configures object detection conditions. Use RaycastParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.

Return

RaycastResult

A result object containing information about the first object the ray collided with along its path. Returns nil if no collision occurs.

Code Samples

RaycastDeprecated

Raycast The previous version of the Raycast method. Maintained for backward compatibility; use Raycast for new projects.

Parameters

Vector3 InOrigin

The origin point from which the ray is cast.

Vector3 InDirection

A vector representing the ray’s direction; its length (size) also determines the detectable distance.

RaycastParams InRaycastParams

A settings object that configures object detection conditions. Use RaycastParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.

Return

RaycastResult

A result object containing information about the first object the ray collided with along its path. Returns nil if no collision occurs.

Code Samples

RaycastMulti

Casts a ray based on a given origin and direction to detect all objects along its path, and returns the results as an array. Unlike Raycast, which returns only the first collision, it returns all collision results along the ray's path. Useful for penetration effects and multiple target detection.

Parameters

Vector3 InOrigin

The origin point from which the ray is cast.

Vector3 InDirection

A vector representing the ray’s direction; its length (size) also determines the detectable distance.

RaycastParams InRaycastParams

A settings object that configures object detection conditions. Use RaycastParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.

Return

array

An array of all RaycastResult objects detected along a ray’s path.

Code Samples

RaycastMultiByObject

Casts a ray based on object query parameters, detects all objects along its path, and returns the results as an array. It works like RaycastMulti, but performs collision detection based on object type.

Parameters

Vector3 InOrigin

The origin point from which the ray is cast.

Vector3 InDirection

A vector representing the ray’s direction; its length (size) also determines the detectable distance.

CollisionQueryParams InQueryParams

An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored.

Return

array

An array of all RaycastResult objects detected along a ray’s path.

Code Samples

RaycastSingleByObject

Casts a ray based on object query parameters, detects the first colliding object along its path, and returns a RaycastResult object. It works like Raycast, but performs collision detection based on object type.

Parameters

Vector3 InOrigin

The origin point from which the ray is cast.

Vector3 InDirection

A vector representing the ray’s direction; its length (size) also determines the detectable distance.

CollisionQueryParams InQueryParams

An object that can configure detailed conditions for collision queries, including which objects to be detected or ignored.

Return

RaycastResult

A result object containing information about the first object the ray collided with along its path. Returns nil if no collision occurs.

Code Samples

Spherecast

Moves a sphere-shaped region defined by a given origin and radius into a specified direction, detects any objects along its path, and returns the result as a RaycastResult object. It works like Raycast, but can detect a broader area of Objects as it detects collision in a sphere shape instead of a ray shape. Useful for melee weapon detections and wide-area collision detections.

Parameters

Vector3 InOrigin

The origin point of a sphere.

number InRadius

The radius of a sphere.

Vector3 InDirection

A vector representing the sphere’s movement direction; its length (size) also determines the detectable distance.

RaycastParams InRaycastParams

A settings object that configures object detection conditions. Use RaycastParams to exclude specific parts or set a collision group. If not specified, the default settings apply, and all objects become potential detection targets.

Return

RaycastResult

A result object containing information about the first object the sphere collided with along its path. Returns nil if no collision occurs.

Code Samples

Events

Last updated