reckfellENGINE

Interpolation: cameras, mouse input and MultiMesh

A complete camera reading visual transforms, with exception, buffer and instance-reuse rules.

On this page

Per-frame following camera

When a target moves in physics but a camera reads ordinary GlobalPosition in _Process, the camera can follow stepped state rather than the pose already smoothed by rendering. For manual per-frame following, this camera reads GetGlobalTransformInterpolated and uses Off to avoid a second automatic smoothing stage.

Create a separate Camera3D with InterpolatedFollowCamera. Place it outside the target's moving branch, assign Target and make it current. In InterpolationDemo3D, assign Smooth and disable Current on the original camera. Enable global interpolation. Offset uses world axes; this is a simple offset camera without obstruction handling or a spring.

InterpolatedFollowCamera.cs
C#
using Reckfell;

public partial class InterpolatedFollowCamera : Camera3D
{
    [Export] public Entity3D? Target { get; set; }
    [Export] public Vector3 Offset { get; set; } = new(0,3,7);
    public override void _Ready() { PhysicsInterpolationMode = PhysicsInterpolationModeEnum.Off; }
    public override void _Process(double delta)
    {
        if (Target is null || !ReckfellObject.IsInstanceValid(Target) || !Target.IsInsideTree() || !Offset.IsFinite() || Offset.LengthSquared() < .0001f) return;
        Vector3 point = Target.GetGlobalTransformInterpolated().Origin;
        GlobalPosition = point + Offset;
        Vector3 direction = -Offset.Normalized();
        if (Mathf.Abs(direction.Dot(Vector3.Up)) < .999f) LookAt(point,Vector3.Up);
    }
}

Zero/nonfinite Offset is rejected. A nearly vertical direction is not passed to LookAt with a parallel Up; select a suitable offset for the intended orientation. A missing/freed target preserves the camera position. This is not a game error screen; assigning the target remains level logic.

Another valid approach moves the camera in physics and uses automatic smoothing. Do not stack both approaches without a deliberate reason. Manual _Process uses visual state for drawing and physical state for game rules. Reading the visual transform in the current implementation needs no separate _Ready initialization.

Mouse input and separate branches

Store yaw/pitch in ordinary input fields and apply visual rotation in the chosen phase. Mouse camera rotation need not always wait for a physics tick, but it must not silently overwrite the body's authoritative transform. Sensitivity, pointer capture, pitch bounds and body/camera separation require a separate controller; this example does not pretend to be a complete first-person camera.

Off disables local-transform interpolation, not the mathematical contribution of a moving parent. A separate camera branch is therefore clearer than arbitrary child switches. Read GetGlobalTransformInterpolated during a rendered frame; its physics-phase result is not an intermediate image pose. With global interpolation disabled it passes through ordinary transform, allowing checks without rewriting the code.

MultiMesh

Instance indices associate previous and current poses. Maintain stable index-to-object mapping. When creating, teleporting or reusing an index, assign its new transform then call ResetInstancePhysicsInterpolation for that index. Resetting an Entity parent does not replace deliberate management of all instance histories.

For bulk updates, SetBufferInterpolated accepts current and previous buffers. Layout/length must match TransformFormat, InstanceCount, colors and custom data; an arbitrary array of matrices is not a valid buffer. Apply data on a consistent tick. PhysicsInterpolationQuality selects the available path's quality/cost; it does not repair mismatched IDs, layouts or previous states. See MultiMesh API for method detail.

Profile hidden branches, instance counts, buffer updates and cameras. Reading a visual transform need not cost the same for every visible/hidden hierarchy. The automated test checks this camera, local 3D hierarchy and simple-object resets, not every MultiMesh, particle, XR, mouse-look or collision-camera setup.

Reckfell Engine documentationBack to top ↑
QUICK LINKSGetting startedEntity hierarchyC# & .NET 10Scenes and prefabs
Reckfell guides and full API K
reckfellENGINE
RECKFELL ACCOUNT

Sign in

Sign in to your Reckfell account.

One account for the entire Reckfell platform.