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