Skip to main content

RaycastResult

A userdata object representing a raycast result.

A raycast result is a collection of data received from a raycast.
The result contains information about where the raycast travelled and what objects it eventually hit.

Raycast results are the result of functions such as sm.physics.raycast, sm.physics.distanceRaycast and sm.localPlayer.getRaycast.

Values:
  • directionWorld [ Vec3 ]

    • Get: The raycast's direction vector.
  • fraction [ number ]

    • Get: The fraction (0 - 1) of the distance reached until collision, divided by the ray's length.
  • normalLocal [ Vec3 ]

    • Get: The normal vector of the hit surface, relative to the target's rotation.
  • normalWorld [ Vec3 ]

    • Get: The normal vector of the hit surface.
  • originWorld [ Vec3 ]

    • Get: The raycast's start position.
  • pointLocal [ Vec3 ]

    • Get: The world position of the hit point, relative to the target's position.
  • pointWorld [ Vec3 ]

    • Get: The world position of the hit point.
  • type [ string ]

    • Get: The physics type of the shape that was hit.
  • valid [ bool ]

    • Get: Whether the raycast hit a target or not.

Functions

getAreaTrigger

raycastResult:getAreaTrigger()

Returns the AreaTrigger hit by the raycast, if the result type is areaTrigger.

Arguments:
Returns:

getBody

raycastResult:getBody()

Returns the Body hit by the raycast, if the result type is body.

Arguments:
Returns:

getCharacter

raycastResult:getCharacter()

Returns the Character hit by the raycast, if the result type is character.

Arguments:
Returns:

getHarvestable

raycastResult:getHarvestable()

Returns the Harvestable hit by the raycast, if the result type is harvestable.

Arguments:
Returns:

getJoint

raycastResult:getJoint()

Returns the Joint hit by the raycast, if the result type is joint.

Arguments:
Returns:

getLiftData

raycastResult:getLiftData()

Returns the Lift hit by the raycast, if the result type is lift.

Arguments:
Returns:
  • [ Lift ]: The lift.
  • [ bool ]: Whether you are looking at the lift's top face or not. (true if you are looking at the top face)

getShape

raycastResult:getShape()

Returns the Shape hit by the raycast, if the result type is shape.

Arguments:
Returns: