Skip to content

PhysicsAPI reference

Struct RayHit

Namespace: MicroEngine.Physics
Assembly: MicroEngine.Physics.dll
Guide: Physics worlds

The closest shape a ray hit (RayCast).

C#
public readonly struct RayHit : IEquatable<RayHit>

Implements

IEquatable<RayHit>

Constructors

RayHit(ShapeId, EntityId, Vector2, Vector2, float)

The closest shape a ray hit (RayCast).

C#
public RayHit(ShapeId Shape, EntityId Owner, Vector2 Point, Vector2 Normal, float Fraction)

Parameters

Shape ShapeId

The shape hit.

Owner EntityId

The entity owning that shape’s body.

Point Vector2

Where the ray entered it.

Normal Vector2

The surface normal there, unit length, facing the ray’s origin.

Fraction float

How far along the ray, from 0 (its start) to 1 (its end).

Properties

Fraction

How far along the ray, from 0 (its start) to 1 (its end).

C#
public float Fraction { get; init; }

Property Value

float

Normal

The surface normal there, unit length, facing the ray’s origin.

C#
public Vector2 Normal { get; init; }

Property Value

Vector2

Owner

The entity owning that shape’s body.

C#
public EntityId Owner { get; init; }

Property Value

EntityId

Point

Where the ray entered it.

C#
public Vector2 Point { get; init; }

Property Value

Vector2

Shape

The shape hit.

C#
public ShapeId Shape { get; init; }

Property Value

ShapeId

Methods

Deconstruct(out ShapeId, out EntityId, out Vector2, out Vector2, out float)

C#
public void Deconstruct(out ShapeId Shape, out EntityId Owner, out Vector2 Point, out Vector2 Normal, out float Fraction)

Parameters

Shape ShapeId

Owner EntityId

Point Vector2

Normal Vector2

Fraction float

Equals(object)

C#
public override bool Equals(object obj)

Parameters

obj object

Returns

bool

Equals(RayHit)

C#
public bool Equals(RayHit other)

Parameters

other RayHit

Returns

bool

GetHashCode()

C#
public override int GetHashCode()

Returns

int

ToString()

C#
public override string ToString()

Returns

string

Operators

operator ==(RayHit, RayHit)

C#
public static bool operator ==(RayHit left, RayHit right)

Parameters

left RayHit

right RayHit

Returns

bool

operator !=(RayHit, RayHit)

C#
public static bool operator !=(RayHit left, RayHit right)

Parameters

left RayHit

right RayHit

Returns

bool