Skip to content
Jérôme Leclercq edited this page Dec 8, 2020 · 1 revision

API: physics.Trace

Description:

Trace a ray between two positions and returns the first hit entity data.

Prototype:

physics.Trace(layer: integer, startPos: vec2, endPos: vec2) -> result: table | nil

Parameters:

  1. layer: The layer to query.
  2. startPos: The starting position of the ray.
  3. endPos: The end position of the ray.

Returns:

  1. result: A table containing data about the intersection (or nil if no entity was hit).
    Fields:
    • fraction: number : A number ranging from 0 to 1 indicating how far the ray travelled before hitting the entity.
    • hitPos: vec2 : The hit position.
    • hitNormal: vec2 : The hit position.
    • hitEntity: Entity : The hit entity.
Clone this wiki locally