Struct RaycastHit
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
EntityEntityThe entity associated with the hit body, or null when the body has none.
BodyIdB2BodyIdThe body hit by the ray.
ShapeIdB2ShapeIdThe specific shape on the body that was hit.
PointVector2World-space intersection point.
NormalVector2World-space surface normal at the hit.
DistancefloatDistance from the ray origin to the hit.
FractionfloatNormalized 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
Entity
The entity associated with the hit body, or null when the body has none.
public Entity? Entity { get; init; }
Property Value
Fraction
Normalized fraction along the ray in range [0,1].
public float Fraction { get; init; }
Property Value
Normal
World-space surface normal at the hit.
public Vector2 Normal { get; init; }
Property Value
Point
World-space intersection point.
public Vector2 Point { get; init; }
Property Value
ShapeId
The specific shape on the body that was hit.
public B2ShapeId ShapeId { get; init; }
Property Value
- B2ShapeId