Camera Projection Matrix Is One Frame Behind When Converting Screen to World Coordinates

When moving a built-in camera component, using the camera’s projection matrix to convert screen coordinates to world coordinates always ends up being one frame behind. This has been a long-standing issue.

I understand that the camera matrix is calculated in the render script, and the render script runs after the logic script, which causes this one-frame delay.

Is there any existing workaround for this problem, or do we need to wait for the engine to add a last_update (or similar) feature?

camera_test.zip (33.1 KB)
camera_test

In 1.12.0 (now in beta) there is already late_update()introduced: Defold 1.12.0 BETA

1 Like

defold1.12: using the built-in camera.screen_to_world and placing it in last_update still delays one frame, and the problem still exists.

camera_test-1.12.zip (32.9 KB)

1 Like

A temporary workaround for this issue is to manually apply the current frame’s offset so that the latest value is used. While this approach is more of a patch than a true fix, it does provide a way to bypass the limitation.
camera_test-solved.zip (33.0 KB)
demo

1 Like