Class Collision.Ray

Casts a collision ray in the game world.

Provides collision information for collided rooms, moveables, and statics.

Functions

Ray(pos, roomNumber, direction, dist, [hitMoveables], [hitStatics], [penetrate]) Create a ray at a specified world position, direction, and distance in a room.
Ray:GetRoom() Get the room hit by the ray.
Ray:GetRoomPosition() Get the position of the room geometry where the ray hit.
Ray:GetRoomDistance() Get the distance from the ray origin point to the room hit position.
Ray:GetRoomNormal() Get the surface normal of the room geometry where the ray hit.
Ray:GetMoveable() Get the first moveable hit by the ray.
Ray:GetMoveables() Gets all moveables hit by the ray.
Ray:GetMoveablePosition() Get the position of the moveable where the ray hit.
Ray:GetMoveableDistance() Get the distance from the ray origin to the first moveable hit position.
Ray:GetStatic() Get the first static mesh hit by the ray.
Ray:GetStatics() Gets all statics hit by the ray.
Ray:GetStaticPosition() Get the position of the first static mesh hit by the ray.
Ray:GetStaticDistance() Get the distance from the ray origin to the first static mesh hit position.
Ray:HitRoom([name]) Check if the ray hit a room.
Ray:HitMoveable([name]) Check if the ray hit a moveable.
Ray:HitStatic([name]) Check if the ray hit a static mesh.
Ray:Preview() Preview this ray in the Collision Stats debug page.


Functions

Ray(pos, roomNumber, direction, dist, [hitMoveables], [hitStatics], [penetrate])
Create a ray at a specified world position, direction, and distance in a room.

Parameters:

  • pos Vec3 World position.
  • roomNumber int Origin room number.
  • direction Vec3 Direction vector.
  • dist float Maximum distance the ray can travel.
  • hitMoveables IntersectionType Collide with moveables. Disable when not needed or required to optimize performance. Default: Collision.IntersectionType.BOX.
  • hitStatics IntersectionType Collide with static meshes. Disable when not needed or required to optimize performance. Default: Collision.IntersectionType.BOX.
  • penetrate bool Continue the ray test after the first hit. Enable this when you need to collect all collision information beyond the first occlusion point. Default: false.

Returns:

    Ray A new ray object.
Ray:GetRoom()
Get the room hit by the ray.

Returns:

    Room Room object. nil: no room was hit.
Ray:GetRoomPosition()
Get the position of the room geometry where the ray hit.

Returns:

    Vec3 Hit position. nil: no room was hit.
Ray:GetRoomDistance()
Get the distance from the ray origin point to the room hit position.

Returns:

    float Hit distance. nil: no room was hit.
Ray:GetRoomNormal()
Get the surface normal of the room geometry where the ray hit.

Returns:

    Vec3 Surface normal. nil: no room was hit, or no valid room geometry was hit.
Ray:GetMoveable()
Get the first moveable hit by the ray. Moveable hits will be detected only if hitMoveables setting was enabled while creating a ray.

Returns:

    Moveable Moveable object. nil: no moveable was hit.
Ray:GetMoveables()
Gets all moveables hit by the ray. Multiple moveable hits will be detected only if hitMoveables and penetrate settings were enabled while creating a ray.

Returns:

    table Table of moveables hit by the ray. nil: no moveables were hit.
Ray:GetMoveablePosition()
Get the position of the moveable where the ray hit. Valid position will be returned only if hitMoveables setting was enabled while creating a ray.

Returns:

    Vec3 Hit position. nil: no moveable was hit.
Ray:GetMoveableDistance()
Get the distance from the ray origin to the first moveable hit position. Valid distance will be returned only if hitMoveables setting was enabled while creating a ray.

Returns:

    float Hit distance. nil: no moveable was hit.
Ray:GetStatic()
Get the first static mesh hit by the ray. Static mesh hits will be detected only if hitStatics setting was enabled while creating a ray.

Returns:

    Static Static mesh object. nil: no static mesh was hit.
Ray:GetStatics()
Gets all statics hit by the ray. Multiple statics hits will be detected only if hitStatics and penetrate settings were enabled while creating a ray.

Returns:

    table Table of statics hit by the ray. nil: no statics were hit.
Ray:GetStaticPosition()
Get the position of the first static mesh hit by the ray. Valid position will be returned only if hitStatics setting was enabled while creating a ray.

Returns:

    Vec3 Hit position. nil: no static mesh was hit.
Ray:GetStaticDistance()
Get the distance from the ray origin to the first static mesh hit position. Valid distance will be returned only if hitStatics setting was enabled while creating a ray.

Returns:

    float Hit distance. nil: no static mesh was hit.
Ray:HitRoom([name])
Check if the ray hit a room. If a room name is provided, returns true only when the hit occurs with the relevant room geometry.

Parameters:

  • name string Name of the room to check for. Optional.

Returns:

    bool Room hit status. true if a room was hit, false otherwise.
Ray:HitMoveable([name])
Check if the ray hit a moveable. Moveable hits will be detected only if hitMoveables setting was enabled while creating a ray. If a moveable name is provided, returns true only when the hit occurs with the relevant moveable.

Parameters:

  • name string Name of the moveable to check for. Optional.

Returns:

    bool Moveable hit status. true if a moveable was hit, false otherwise.
Ray:HitStatic([name])
Check if the ray hit a static mesh. Static mesh hits will be detected only if hitStatics setting was enabled while creating a ray. If a static mesh name is provided, returns true only when the hit occurs with the relevant static mesh.

Parameters:

  • name string Name of the static mesh to check for. Optional.

Returns:

    bool Static mesh hit status. true if a static mesh was hit, false otherwise.
Ray:Preview()
Preview this ray in the Collision Stats debug page.
generated by TEN-LDoc (a fork of LDoc 1.4.6)