I have come across a problem while trying to use a tween to move a Camera2D node. I noticed the children of the node don't seem to move together with their parent (they seem to be one frame ahead). In addition, I tried to print the following boolean value at each frame:
child.global_position.x == camera.global_position.x + child.position.x
And it is true before & after the interpolation, but while the tween is playing it alternates between true and false, which seems very strange, as I believe it should always be true in all situations.
The interpolation starts at the click of an arrow, which calls the _on_click function. Here is the script:
export var movement_vector = Vector2(1560, 0)
onready var camera: Camera2D = get_tree().get_root().get_node("Gumba/Camera2D")
var tween: Tween = camera.get_node("Tween")
if not tween.is_active():
var start_position = camera.global_position
var end_position = start_position + movement_vector
tween.interpolate_property(camera, "global_position", start_position, end_position, 1, Tween.TRANS_CUBIC, Tween.EASE_IN_OUT)
print(child.global_position.x == camera.global_position.x + child.position.x)
Here is a video of the phenomenon (the child is the blue thing to the right): https://streamable.com/f5e0ui
Thanks in advance for any help.
EDIT: I just noticed that the problem is related to whether the tween is instanced before or after the camera (in my case the tween was the camera's child, hence instanced after it). If I move it to a position where it's instanced before, the problem disappears. Am I missing something or is this a bug?