Description
Changelog
Reviews (0)

Time Rewinder Delta

A memory-optimized time rewind mechanic for Godot 4, for 2D & 3D games. Useful for gameplay mechanics (rewind powers, "undo" mechanics, replay/killcam systems) or for debugging.

Instead of storing a full copy of every tracked property every frame, it uses keyframe + delta compression: a full value is stored periodically (a keyframe), and every frame in between only stores the small change since the previous frame, quantized down to as few bytes as you need. This keeps memory usage low even for long rewind durations or many tracked objects.

Installation

  1. Copy the addons/TimeRewinderDelta folder into your project's addons/ folder.
  2. Enable the plugin in Project > Project Settings > Plugins.
  3. A new node type, TimeRewinderDelta, becomes available in the "Create New Node" dialog.

Quick start

  1. Add a TimeRewinderDelta node anywhere in your scene.
  2. In the Inspector, add an entry to Tracked Nodes, and for each entry:
    • Set Node Path to the node you want to rewind.
    • Set Properties to the list of property names to record (e.g. global_position, rotation, velocity).
  3. Call rewind() to start rewinding, and stop_rewind() to stop early. Rewinding also stops automatically once the recorded history runs out.
@onready var rewinder: Node = $TimeRewinderDelta

func _on_rewind_button_pressed() -> void:
    rewinder.rewind()

func _on_rewinder_done_rewinding() -> void:
    print("Back to the past!")

Connect to the done_rewinding signal if you need to know when a rewind finishes (either because you called stop_rewind(), or because the buffer ran out of recorded history).

While TimeRewinderDelta is not rewinding, it automatically records the tracked properties every physics frame. While it is rewinding, it automatically applies past values every physics frame and disables physics processing on any tracked CollisionObject2D/CollisionObject3D so they don't fight the manual rewind.

Tracking nodes dynamically

You can also register a node at runtime (e.g. right after spawning it) instead of listing it in the Inspector:

var enemy := enemy_scene.instantiate()
some_container.add_child(enemy)  # must be in the tree first
rewinder.add_rewindable_node(enemy.get_path(), ["global_position", "rotation"])

Always pass an absolute NodePath (node.get_path(), not some_other_node.get_path_to(node)) so it resolves correctly regardless of where the TimeRewinderDelta node sits in your scene tree.

The last three arguments (new_keyframes_modulo, new_precision, new_bytes_per_delta) are optional and default to the node's own Inspector settings — only override them if this particular node genuinely needs different tuning (see below).

Configuration

Property Description
rewind_duration How far back (in seconds) you can rewind.
keyframes_modulo How many frames between two full keyframes. Must evenly divide rewind_duration * physics_ticks_per_second. Lower = faster rewind-start reads and less drift, at a small memory cost; higher = more memory-efficient, at the cost of very slightly more precision drift right before a keyframe.
precision The size of one quantization step (e.g. 0.001 = deltas are rounded to the nearest millimeter for a position in meters). Smaller = finer resolution, larger = coarser but cheaper.
bytes_per_delta Bytes used to store each delta component (1, 2 or 4). Determines both memory cost per frame and the max change per property per physics tick you can record without corruption (see below).
speed_scale How much faster/slower than real-time the rewind plays back.

Memory footprint

Calling rewind() prints the total memory used by the recorded history to the console. You can also query it directly per tracked node:

for tracked_node in rewinder.tracked_nodes:
    print(tracked_node.get_size(), " bytes")

Limitations

  • Supported property types: bool, int, float, Vector2/2I, Vector3/3I, Vector4/4I, Quaternion.
  • int properties are reconstructed through floating-point accumulation and rounded back to the nearest integer; values beyond ~16.7 million (float32's exact integer range) may lose precision.

License

MIT

Credits

Changelog for version v1.0.1

No changelog provided for this version.

Reviews

Time Rewinder Delta has no reviews yet.

Login to write a review.

Consider supporting the creators!

If you enjoyed this asset consider supporting its creator. Follow the link below.