Vixen
02b45cc4

PhysicsInterpolationSystem

system Core/Vixen.Physics/Ecs/PhysicsSystems.cs:136
csharp
public sealed class PhysicsInterpolationSystem

Draws every body between where it was at the last step and where it is at this one, so a 60 Hz simulation looks smooth at any frame rate.

No guide page documents this yet — the page shows what the code says about itself.

As a system

Phase
LateUpdate

Remarks

Writes LocalTransform, so what the renderer sees is the interpolated pose and what the simulation sees is the stepped one. The next fixed step overwrites it from the body, which is why interpolating into the same component is safe rather than cumulative.

⚠ In LateUpdate and not PreRender, because a camera that follows a body is what everybody actually looks at. That phase's own summary is "after everything has moved — cameras that follow, constraints that correct", and a camera solving there against a pose this system had not smoothed yet is a camera that steps at the fixed rate however smooth the body is. The symptom is the opposite of the obvious one: the character sits perfectly still relative to the frame and the entire world judders around it, which reads as a jittery camera and sends you looking at the camera.

Still before TransformSystem, which is what matters for the renderer, and still after every fixed step this frame ran.

Only entities that have asked for it, by carrying a PhysicsInterpolation component. A body whose motion is being watched by gameplay code — a projectile, a hit test — should not have one, because the smoothed pose is deliberately a step behind.

⚠ A zeroed PhysicsInterpolation holds two poses at the world origin, and this lerps between them and writes the result — so an entity handed a default one is dragged to (0, 0, 0) until a step has filled both. Seed it with the pose the entity is being created at.

Fields and properties (1)

  • public SystemAccess Access

    What this system reads and writes.

Methods (2)

  • public PhysicsInterpolationSystem(FixedStepAccumulator accumulator)

    Draws every body between where it was at the last step and where it is at this one, so a 60 Hz simulation looks smooth at any frame rate.

  • public override JobHandle Update(in SystemContext context, JobHandle dependency)

    Runs the system.

Used by (2)

  • PhysicsDebugDrawSystemVixen.Physics
  • PhysicsSystemsVixen.Physics