Table of Contents

Struct RaycastHit

Namespace
Stride.CommunityToolkit.Box2D
Assembly
Stride.CommunityToolkit.Box2D.dll

A 2D raycast hit with the owning Stride entity resolved, as returned by Raycast(Vector2, Vector2, float) and RaycastAll(Vector2, Vector2, float). See QueryRaycastHit for the raw engine-agnostic variant.

public readonly record struct RaycastHit : IEquatable<RaycastHit>
Implements
Inherited Members

Constructors

RaycastHit(Entity?, B2BodyId, B2ShapeId, Vector2, Vector2, float, float)

A 2D raycast hit with the owning Stride entity resolved, as returned by Raycast(Vector2, Vector2, float) and RaycastAll(Vector2, Vector2, float). See QueryRaycastHit for the raw engine-agnostic variant.

public RaycastHit(Entity? Entity, B2BodyId BodyId, B2ShapeId ShapeId, Vector2 Point, Vector2 Normal, float Distance, float Fraction)

Parameters

Entity Entity

The entity associated with the hit body, or null when the body has none.

BodyId B2BodyId

The body hit by the ray.

ShapeId B2ShapeId

The specific shape on the body that was hit.

Point Vector2

World-space intersection point.

Normal Vector2

World-space surface normal at the hit.

Distance float

Distance from the ray origin to the hit.

Fraction float

Normalized fraction along the ray in range [0,1].

Properties

BodyId

The body hit by the ray.

public B2BodyId BodyId { get; init; }

Property Value

B2BodyId

Distance

Distance from the ray origin to the hit.

public float Distance { get; init; }

Property Value

float

Entity

The entity associated with the hit body, or null when the body has none.

public Entity? Entity { get; init; }

Property Value

Entity

Fraction

Normalized fraction along the ray in range [0,1].

public float Fraction { get; init; }

Property Value

float

Normal

World-space surface normal at the hit.

public Vector2 Normal { get; init; }

Property Value

Vector2

Point

World-space intersection point.

public Vector2 Point { get; init; }

Property Value

Vector2

ShapeId

The specific shape on the body that was hit.

public B2ShapeId ShapeId { get; init; }

Property Value

B2ShapeId