Table of Contents

Struct RaycastHit

Namespace
Box3D
Assembly
Box3D.NET.dll

Where a ray met a shape.

public readonly record struct RaycastHit : IEquatable<RaycastHit>

Implements

Inherited Members

Examples

RaycastHit hit = world.RaycastClosest(camera.Position, camera.Forward * 100.0f);
if (hit.Hit)
{
    PlaceDecal(hit.Point, hit.Normal);
    float distance = hit.Fraction * 100.0f;
}

Properties

ChildIndex

Gets the child index for a compound shape, or minus one otherwise.

Fraction

Gets how far along the ray the hit occurred, from zero at the origin to one at the end.

Hit

Gets a value indicating whether the ray hit anything.

Normal

Gets the outward surface normal at the point of intersection.

Point

Gets the world-space point of intersection.

Shape

Gets the shape that was hit.

TriangleIndex

Gets the triangle index for a mesh or height field, or minus one otherwise.

UserMaterialId

Gets the user material identifier at the hit point, which can vary per triangle on a mesh or height field.