WorldRoot
WorldRoot : Instance
Overview
This code defines the WorldRoot
class, a subclass of Instance
, designed for raycasting and instance management within game worlds. It includes methods such as FindPartOnRay and Raycast to perform collision queries and find parts in the scene. The WorldRoot also provides a templated function, FindInstanceByPred, for searching instances based on custom predicates and internal helper functions for handling parameters initialization and hit result processing. This functionality is intended for use within a Lua-based game engine environment.
Description
WorldRoot is a core component in Overdare Studio's Lua API, serving as the root for managing virtual worlds within its Lua environment. It provides essential functionality to interact with game elements and manipulate them through Lua scripts. In terms of structure, it bridges the gap between C++ engine and Lua scripting languages for controlling various aspects of a game world. Key methods in WorldRoot include 'FindPartOnRay' for identifying and retrieving specific game elements based on raycast information and 'Raycast' for performing ray-tracing operations within the game environment. Both functions enable
Properties
Methods
FindPartOnRay
The FindPartOnRay
method is used to detect and retrieve the first part along a given ray's trajectory within the world. It allows for raycasting operations and supports options for filtering through parameters like ignoring specific descendants, treating terrain cells as cubes, and ignoring water bodies. This method is useful for implementing precise object interactions and collision detection in a game environment.
Parameters
Ray
InRay
Instance
InIgnoreDescendantsInstance
bool
bInTerrainCellsAreCubes
bool
bInIgnoreWater
Return
array
Code Samples
Raycast
The Raycast
method performs a ray-tracing operation from a given origin in a specific direction within the game world. It returns detailed information about the first object hit, if any, along the ray's path. This method is essential for physics interactions, line-of-sight calculations, and gameplay mechanics that rely on precise spatial queries.
Parameters
Vector3
InOrigin
Vector3
InDirection
RaycastParams
InRaycastParams
Return
ULuaRaycastResult
Code Samples
GetPartBoundsInBox
GetPartBoundsInBox computes the parts intersecting or within a specified box area, centered at a given point and with defined size. This method is particularly useful for detecting objects in a specified region, implementing area-of-effect mechanics, and determining spatial relationships between items within a predefined boundary.
Parameters
CFrame
InCenter
Vector3
InSize
OverlapParams
InOverlapParams
Return
array