Skip to content

PhysicsAPI reference

Struct MoveResult

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

What Move did: where the body ended, how far it went, and every surface it was stopped by or touches at the end (within the backend’s Skin), each one with its normal. A kinematic body’s contacts and its ground come from here, never from ContactEvents.

C#
public readonly struct MoveResult

Constructors

MoveResult(Vector2, Vector2, Vector2, ReadOnlySpan<MoveContact>)

Creates a result from the contacts the backend found (the first MaxContacts are kept).

C#
public MoveResult(Vector2 position, Vector2 delta, Vector2 up, ReadOnlySpan<MoveContact> contacts)

Parameters

position Vector2

The body’s origin after the move.

delta Vector2

The displacement actually applied.

up Vector2

The world’s up direction, which tells ground, walls and ceilings apart.

contacts ReadOnlySpan<MoveContact>

The contacts, in the order the backend found them.

Fields

GroundThreshold

The smallest dot product of a contact’s normal with Up that counts as ground (about 45 degrees); a dot product of at most its negation is a ceiling, anything between is a wall.

C#
public const float GroundThreshold = 0.7

Field Value

float

MaxContacts

The most contacts one result holds; further ones are counted in TotalContacts but not kept.

C#
public const int MaxContacts = 8

Field Value

int

Properties

Contacts

The contacts kept, in the order the backend found them.

C#
[UnscopedRef]
public ReadOnlySpan<MoveContact> Contacts { get; }

Property Value

ReadOnlySpan<MoveContact>

Delta

The displacement actually applied (the requested one when nothing was in the way).

C#
public Vector2 Delta { get; }

Property Value

Vector2

Ground

The ground shape (GroundNormal’s); None when not on ground.

C#
public ShapeId Ground { get; }

Property Value

ShapeId

GroundNormal

The most upward ground normal; zero when OnGround is false.

C#
public Vector2 GroundNormal { get; }

Property Value

Vector2

HitCeiling

Whether a contact is a ceiling (its normal points down).

C#
public bool HitCeiling { get; }

Property Value

bool

HitWall

Whether a contact is a wall (neither ground nor ceiling).

C#
public bool HitWall { get; }

Property Value

bool

OnGround

Whether a contact is ground: its normal points up within GroundThreshold.

C#
public bool OnGround { get; }

Property Value

bool

Position

The body’s origin after the move.

C#
public Vector2 Position { get; }

Property Value

Vector2

TotalContacts

How many contacts the backend found; Contacts holds at most MaxContacts of them.

C#
public int TotalContacts { get; }

Property Value

int

Methods

ToString()

C#
public override string ToString()

Returns

string