reckfellENGINE

Interpolation: run the On/Off comparison

One complete Entity2D C# file: identical physics movement with different rendered smoothness.

On this page

Prepare the project

Enable physics/common/physics_interpolation in Project Settings. Temporarily set physics/common/physics_ticks_per_second = 10 for a clear comparison, then restore the project's working frequency. Rendering must substantially exceed 10 frames/s. Use a 640×420 or larger window.

Create a separate level with an Entity2D root, add InterpolationDemo2D.cs, attach it, build and press F6. Keep the root stationary and unscaled. No external assets are required. Blue uses On and white Off, with the same physics X coordinate. Compare motion, then disable the global setting and rerun: local On should not be understood as a separate global system.

Squares using On and Off

InterpolationDemo2D.cs
C#
using System;
using Reckfell;

public partial class InterpolationDemo2D : Entity2D
{
    public Entity2D Smooth { get; private set; } = null!;
    public Entity2D Stepped { get; private set; } = null!;
    public float Speed { get; set; } = 120;
    public int Warps { get; private set; }
    private float _x = 80;
    private float? _warp;
    public override void _Ready()
    {
        Smooth = Marker(new Vector2(_x,120),new Color(.25f,.45f,1),PhysicsInterpolationModeEnum.On);
        Stepped = Marker(new Vector2(_x,260),Colors.White,PhysicsInterpolationModeEnum.Off);
        AddChild(new Label { Text = "On", Position = new Vector2(24,56), Modulate = new Color(.6f,.6f,.6f) });
        AddChild(new Label { Text = "Off", Position = new Vector2(24,196), Modulate = new Color(.6f,.6f,.6f) });
        ResetPhysicsInterpolation();
    }
    private Entity2D Marker(Vector2 position,Color color,PhysicsInterpolationModeEnum mode)
    {
        var marker = new Entity2D { Position = position, PhysicsInterpolationMode = mode };
        marker.AddChild(new Polygon2D { Polygon = new[] { new Vector2(-12,-12),new Vector2(12,-12),new Vector2(12,12),new Vector2(-12,12) }, Color = color });
        AddChild(marker); return marker;
    }
    public void RequestWarp(float x)
    {
        if (!float.IsFinite(x)) throw new ArgumentOutOfRangeException(nameof(x));
        _warp = x;
    }
    public override void _PhysicsProcess(double delta)
    {
        bool reset = _warp.HasValue;
        _x = _warp ?? (_x + Speed * (float)delta); _warp = null;
        if (_x > 560) { _x = 80; reset = true; }
        Smooth.Position = new Vector2(_x,120); Stepped.Position = new Vector2(_x,260);
        if (reset) { ResetPhysicsInterpolation(); Warps++; }
    }
}

What the code does

Only _PhysicsProcess moves objects. Speed 120 pixels/s is multiplied by delta because this code directly changes Position rather than calling MoveAndSlide. At the right boundary it teleports both objects and resets history. RequestWarp schedules a teleport for the next physics tick; continuous ordinary movement does not reset interpolation every frame.

If the difference is absent, check the global setting, actual FPS, entity modes and other _Process scripts writing Position. For no image, check root type, successful C# build, viewport dimensions and project camera/Canvas placement. Before shipping, test integration with the actual hierarchy.

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.