Skip to content

Complete easing for transform changes outside fixed time step #10

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: main
Choose a base branch
from

Conversation

Jondolf
Copy link
Owner

@Jondolf Jondolf commented Apr 12, 2025

Objective

Currently, changing the Transform of an interpolated or extrapolated entity outside of the fixed time step (e.g. in Update) disables easing until the start of the next fixed time step. It effectively teleports the entity and interrupts easing.

While supporting Transform changes outside the fixed time step is useful, this moment where easing is not applied has been a major source of annoyance for many users. It means that mutably accessing the Transform in any capacity can cause visible stutter to movement. This negatively impacts cases such as:

  • Y-sorting in 2D (dynamically changing Z coordinate based on Y coordinate to emulate depth)
  • Teleporting a character to smoothly wrap around an "infinite" world
  • big_space grid cell transitions

We need a way to teleport entities without breaking easing.

Solution

Rework reset_easing_states_on_transform_change. Changing a Transform in a schedule like Update will now teleport the entity such that the current eased transform matches the new target transform, but the start and end easing states are updated such that the existing easing is still carried out, just from the new transform. This results in teleports that doesn't break easing.

However, it also means that the end state of the interpolation won't perfectly match the value that the Transform was set to. I believe this is inevitable if we want the easing to be carried out smoothly. For cases where you do want a true teleportation without any easing (the old behavior), there is now a ResetEasing command. In a way, it is similar to Godot's reset_physics_interpolation method.

Below you can see an object being teleported backwards by changing its Transform in Update.

2025-04-12.19-48-55.mp4

If we make the camera follow the entity, we see that the movement remains entirely visually smooth, and we don't even see the teleportation happening.

2025-04-12.19-49-23.mp4

Previously, the object stopped for a while whenever it was teleported.


Migration Guide

Changing the Transform of an interpolated or extrapolated entity outside the fixed time step, such as in Update, no longer interrupts easing. This allows things like:

  • Y-sorting in 2D (dynamically changing Z coordinate based on Y coordinate to emulate depth)
  • Teleporting a character to smoothly wrap around an "infinite" world
  • big_space grid cell transitions

without any visual stutter.

However, a side effect of this is that the Transform of the entity may not perfectly match the value it was set to after easing has been completed for the current time step.

To teleport an entity without any easing, or to otherwise temporarily disable easing, you may use the ResetEasing command.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant