RaycastHit¶
Type
RaycastHit describes a hit from Physics.Raycast.
Entity¶
Entity is the hit Entity, or nil if destroyed.
Position¶
Position is the hit point in world units.
Normal¶
Normal is the outward unit normal at Position.
Distance¶
Distance is the distance in units from the ray origin to Position.
Material¶
Material is the name of the hit entity's material, or "" when the entity has no material or was destroyed.
LocalPosition¶
LocalPosition is the hit point in the hit entity's own frame, the frame of ToLocal, which ignores Size. For a ray without AtTick, hit.Entity:ToGlobal(hit.LocalPosition) returns Position.
Under AtTick, LocalPosition is the hit point on the entity at the rewound pose the ray tested, so ToGlobal returns where that point on the entity is now, not Position. Use it to place a wound or decal on a character that has moved since the shot.
A client ray tests the poses that client draws, so its LocalPosition is in the frame of the entity as drawn.
When Entity is nil, LocalPosition equals Position.
LocalNormal¶
LocalNormal is the outward unit normal in the hit entity's own frame at the pose the ray tested. On a face of a box it is a unit axis, such as (0, 0, -1) for the front face. For a ray without AtTick, hit.Entity:ToGlobalDirection(hit.LocalNormal) returns Normal. Under AtTick it returns the normal of the same face of the entity now.
When Entity is nil, LocalNormal equals Normal.