RaycastManager

Summary

Methods

Method Returns
GetEntityInRaycast(distance: float) Entity | nil
Raycast(from: Vec3, to: Vec3, flags: RayCastFlags) RayCastHit | nil
SpatialRaycast(from: Vec3, to: Vec3, flags: SpatialQueryFlags) Entity{}
DetailedRaycast(from: Vec3, to: Vec3, maxHits: int, materialFlags: MaterialFlags, flags: RayCastFlags) RayCastHit{}
CollisionRaycast(from: Vec3, to: Vec3, maxHits: int, materialFlags: MaterialFlags, flags: RayCastFlags) RayCastHit{}

Methods

GetEntityInRaycast

GetEntityInRaycast(distance: float): Entity | nil

It is using the client camera transform as a base.

Parameters

Name Type Description
distance float

Returns

Type Description
Entity | nil

Raycast

Raycast(from: Vec3, to: Vec3, flags: RayCastFlags): RayCastHit | nil

Parameters

Name Type Description
from Vec3
to Vec3
flags RayCastFlags

Returns

Type Description
RayCastHit | nil

Example

Events:Subscribe('UpdateManager:Update', function(deltaTime, updatePass)
    if updatePass ~= UpdatePass.UpdatePass_PreSim then
      return
    end
    local rayCastHit = RaycastManager:Raycast(Vec3(0, 0, 0), Vec3(1, 0, 0), RayCastFlags.DontCheckWater)
    if rayCastHit == nil then
      return
    end
    -- Do something with the rayCastHit here
end)

SpatialRaycast

SpatialRaycast(from: Vec3, to: Vec3, flags: SpatialQueryFlags): Entity{}

Parameters

Name Type Description
from Vec3
to Vec3
flags SpatialQueryFlags

Returns

Type Description
Entity{}

DetailedRaycast

DetailedRaycast(from: Vec3, to: Vec3, maxHits: int, materialFlags: MaterialFlags, flags: RayCastFlags): RayCastHit{}

Parameters

Name Type Description
from Vec3
to Vec3
maxHits int
materialFlags MaterialFlags
flags RayCastFlags

Returns

Type Description
RayCastHit{}

CollisionRaycast

CollisionRaycast(from: Vec3, to: Vec3, maxHits: int, materialFlags: MaterialFlags, flags: RayCastFlags): RayCastHit{}

Parameters

Name Type Description
from Vec3
to Vec3
maxHits int
materialFlags MaterialFlags
flags RayCastFlags

Returns

Type Description
RayCastHit{}