Shape:raycast

Edit

Casts a ray against the Shape and returns the first intersection.

This takes into account the pose of the Shape's collider (if any), as well as its local offset set with Shape:setOffset.



Arguments

NameTypeDescription
x1number The x coordinate of the origin of the ray.
y1number The y coordinate of the origin of the ray.
z1number The z coordinate of the origin of the ray.
x2number The x coordinate of the endpoint of the ray.
y2number The y coordinate of the endpoint of the ray.
z2number The z coordinate of the endpoint of the ray.

Returns

NameTypeDescription
xnumber The x coordinate of the impact point.
ynumber The y coordinate of the impact point.
znumber The z coordinate of the impact point.
nxnumber The x component of the normal vector.
nynumber The y component of the normal vector.
nznumber The z component of the normal vector.
trianglenumber The index of the triangle that was hit, or nil if this is not a MeshShape.

Arguments

NameTypeDescription
originVec3 The origin of the ray.
endpointVec3 The endpoint of the ray.

Returns

NameTypeDescription
xnumber The x coordinate of the impact point.
ynumber The y coordinate of the impact point.
znumber The z coordinate of the impact point.
nxnumber The x component of the normal vector.
nynumber The y component of the normal vector.
nznumber The z component of the normal vector.
trianglenumber The index of the triangle that was hit, or nil if this is not a MeshShape.

See also