Method SolvePlanes
- Namespace
- Box3D
- Assembly
- Box3D.NET.dll
SolvePlanes(Vector3, Span<CollisionPlane>)
Finds the translation closest to the one requested that satisfies every plane.
public static PlaneSolverResult SolvePlanes(Vector3 targetTranslation, Span<CollisionPlane> planes)Parameters
targetTranslationVector3-
The movement the character wants to make.
planesSpan<CollisionPlane>-
The planes to satisfy. Updated in place: each plane's Box3D.CollisionPlane.Push reports how far the solver moved along it.
Returns
- PlaneSolverResult
-
The translation to apply, and the iteration count.
Examples
Span<CollisionPlane> planes = stackalloc CollisionPlane[8];
// ... fill from CollideCapsule ...
PlaneSolverResult result = CharacterMover.SolvePlanes(desiredMove, planes[..count]);
position += result.Translation;
Remarks
This is what makes a character slide along a wall rather than stop dead against it, and what keeps it out of a corner where two walls meet.