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:

Functions:


directionWorld Vec3

Get:

Returns the direction vector of the raycast


fraction number

Get:

Returns the fraction (0–1) of the distance reached until collision divided by the ray's length.


normalLocal Vec3

Get:

Returns the normal vector of the surface that was hit, relative to the target's rotation.


normalWorld Vec3

Get:

Returns the normal vector of the hit surface


originWorld Vec3

Get:

Returns the starting world position of the raycast.


pointLocal Vec3

Get:

Returns the world position of the point that was hit, relative to the target's position.


pointWorld Vec3

Get:

Returns the world position of the point that was hit.


type string

Get:

Returns the physics type of the target that was hit. (See sm.physics.types)


valid boolean

Get:

Returns whether the raycast successfully hit a target.


getAreaTrigger(raycastResult)

Returns the AreaTrigger hit during the raycast. This is only possible if RaycastResult.type is equal to "areaTrigger", otherwise this will return nil.

Parameters:

TypeNameDescription
RaycastResultraycastResultThe raycast result.

Returns:

TypeDescription
AreaTriggerThe areaTrigger target.

getBody(raycastResult)

Returns the Body hit during the raycast. This is only possible if RaycastResult.type is equal to "body", otherwise this will return nil.

Parameters:

TypeNameDescription
RaycastResultraycastResultThe raycast result.

Returns:

TypeDescription
BodyThe body target.

getCharacter(raycastResult)

Returns the Character hit during the raycast. This is only possible if RaycastResult.type is equal to "character", otherwise this will return nil.

Parameters:

TypeNameDescription
RaycastResultraycastResultThe raycast result.

Returns:

TypeDescription
CharacterThe character target.

getHarvestable(raycastResult)

Returns the Harvestable hit during the raycast. This is only possible if RaycastResult.type is equal to "harvestable", otherwise this will return nil.

Parameters:

TypeNameDescription
RaycastResultraycastResultThe raycast result.

Returns:

TypeDescription
HarvestableThe harvestable target.

getJoint(raycastResult)

Returns the Joint hit during the raycast. This is only possible if RaycastResult.type is equal to "joint", otherwise this will return nil.

Parameters:

TypeNameDescription
RaycastResultraycastResultThe raycast result.

Returns:

TypeDescription
JointThe joint target.

getLiftData(raycastResult)

Returns the Lift hit during the raycast. This is only possible if RaycastResult.type is equal to "lift", otherwise this will return nil.

Parameters:

TypeNameDescription
RaycastResultraycastResultThe raycast result.

Returns:

TypeDescription
Lift, boolean The lift; True if the lift is top

getShape(raycastResult)

Returns the Shape hit during the raycast. This is only possible if RaycastResult.type is equal to "body", otherwise this will return nil.

Parameters:

TypeNameDescription
RaycastResultraycastResultThe raycast result.

Returns:

TypeDescription
ShapeThe shape target.