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.
raycastResult[ RaycastResult ]: The raycastResult.
- [ AreaTrigger ]: The areaTrigger.
getBody
raycastResult:getBody()
Returns the Body hit by the raycast, if the result type is body.
raycastResult[ RaycastResult ]: The raycastResult.
- [ Body ]: The body.
getCharacter
raycastResult:getCharacter()
Returns the Character hit by the raycast, if the result type is character.
raycastResult[ RaycastResult ]: The raycastResult.
- [ Character ]: The character.
getHarvestable
raycastResult:getHarvestable()
Returns the Harvestable hit by the raycast, if the result type is harvestable.
raycastResult[ RaycastResult ]: The raycastResult.
- [ Harvestable ]: The harvestable.
getJoint
raycastResult:getJoint()
Returns the Joint hit by the raycast, if the result type is joint.
raycastResult[ RaycastResult ]: The raycastResult.
- [ Joint ]: The joint.
getLiftData
raycastResult:getLiftData()
Returns the Lift hit by the raycast, if the result type is lift.
raycastResult[ RaycastResult ]: The raycastResult.
- [ 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.
raycastResult[ RaycastResult ]: The raycastResult.
- [ Shape ]: The shape.