RayCastResult3D
Package: Libraries.Game.Collision · Inherits from: Libraries.Language.Object
Stores the result of a raycast through a physics scene. Check IsHit to see whether the ray touched an object. When it did, GetHitBody returns that object, GetHitPointWorldSpace returns the contact position in world space, and GetHitNormalWorldSpace returns the surface direction at the contact point. GetFraction tells where the hit lies along the ray segment: 0 is the start and 1 is the end. If the ray hits nothing, IsHit returns false, GetHitBody returns undefined, and GetFraction returns 1. The contact point and normal are only useful when IsHit returns true.
Actions
GetFraction()
Returns where the hit lies along the ray segment. A value of 0 is the start of the segment, and 1 is the end. A value of 1 is also the default when no hit has been found.
Returns
number
GetHitBody()
Returns the object touched by the ray. This value is undefined when the ray did not hit an object.
Returns
GetHitNormalWorldSpace()
Returns the surface direction at the contact point, in world space. This value is useful when the ray hit an object.
Returns
GetHitPointWorldSpace()
Returns the ray's contact position in world space. This value is useful when the ray hit an object.
Returns
IsHit()
Returns whether the ray touched an object. When this is false, the hit body, contact point, and contact normal do not describe a hit.
Returns
boolean
SetFraction(number fraction)
Sets where the hit lies along the ray segment. Use 0 for the start of the segment and 1 for the end.
Parameters
fractionnumber
SetHit(boolean hit)
Sets whether the ray touched an object. Set this to true when a hit is found, or false when the ray does not touch anything.
Parameters
hitboolean
SetHitBody(Libraries.Interface.Item3D hitBody)
Sets the object touched by the ray. Use undefined when the ray did not hit an object.
Parameters
hitBodyLibraries.Interface.Item3D
SetHitNormalWorldSpace(Libraries.Compute.Vector3 hitNormalWorldSpace)
Sets the surface direction at the contact point, in world space.
Parameters
hitNormalWorldSpaceLibraries.Compute.Vector3
SetHitPointWorldSpace(Libraries.Compute.Vector3 hitPoint)
Sets the ray's contact position in world space.
Parameters
hitPointLibraries.Compute.Vector3
SetToDefault()
Sets the raycast result to the default, which is 0,0,0 for all vectors, no hit, no body, and 1.0 for fraction.