I'm developing a minigame with Godot 4.0.3 where I move the camera2D using a tween:

var tween = get_tree().create_tween()
	tween.tween_property(_camera, "position", Vector2(0,-60), 0.2).as_relative().set_trans(Tween.TRANS_LINEAR).set_ease(Tween.EASE_OUT)

The camera2D is the parent of the UI nodes, so the UI should move with the camera. However, when I play this tween, the camera movement leaves the UI behind for a moment, and I don't know why.

I have tested the idea puting the UI as the children of another node and applying this tween to that node, and doing that the UI moves with it's parent like it should. So I don't know why the camera acts different. I checked that the process callback is set on iddle, as the tween and everything else, so it should be syncronized but that's not the case for some reason.

Can you guess what could be causing this? Thanks for reading!

  • cybereality It's disabled.

    The problem I have seems to be this bug: https://github.com/godotengine/godot/issues/74203

    There is a workarround using force_update_scroll() but it only solves the issue with lerping, not with tweens.
    Edit: using force_update_scroll() works if the tween is over a method instead of a property as explained in the github comments.

You shouldn't place children on the camera. You can use a CanvasLayer if you need a static UI.

    cybereality Yeah that sounds like a better approach. But I don't understand why this worked on Godot 3.5 but not in G4. Maybe a bug?

    cybereality I tried your solution. Moved the UI to a CanvasLayer outside of the camera node and now the tween moves a Node that has the camera2D and a sprite2D as its children, but the problem is the same. The movement keeps being out of sync. The camera moves slightly but clearly later than the sprite.

    I notice I made this post at a bad hour and dind't get much attention. It's okay to post it again at a better hour?

    The camera has a smoothing option. Maybe try that instead. There may be some interference.

      cybereality It's disabled.

      The problem I have seems to be this bug: https://github.com/godotengine/godot/issues/74203

      There is a workarround using force_update_scroll() but it only solves the issue with lerping, not with tweens.
      Edit: using force_update_scroll() works if the tween is over a method instead of a property as explained in the github comments.