Skip to content
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

Camera2D moves later than it's parent and its siblings when lerping or tweening its parent #77813

Closed
phantomdesvin opened this issue Jun 3, 2023 · 7 comments · Fixed by #84465

Comments

@phantomdesvin
Copy link

phantomdesvin commented Jun 3, 2023

Godot version

4.0.3 stable

System information

Win 10, rx580 AMD GPU, Intel i5 CPU.

Issue description

When I lerp or tween the position of the parent node of a Camera2D, the Camera2D will start and stop moving slightly but noticeably later than its parent and its siblings. This behaviour is the same with compatibility mode or forward+ mode, and it's the same on the Godot 4.1 dev 4 version. This doesn't happen in Godot 3.5.3.

Steps to reproduce

Add a sprite to have a background. Then a node2D to have a parent. Add a camera2D and a sprite as childs of the node2D. Move the Node2D using lerp or tweens. As the camera and its sibling are being moved at the same time by the parent, you shouldn't see the sibling sprite moving at all, only the background, but because the camera will move slightly later than its sibling sprite, the sprite will move a little bit at the beggining and end of the movement.

Minimal reproduction project

Using the actions:
"ui_up" will lerp the parent node up. Camera2D moves later than its sibling and its parent.
"ui_down" will tween the parent node down. Camera2D moves later than its sibling and its parent.
"ui_right" will just change the parent node position. Camera 2D moves at the same time as its sibling and its parent.

tween parent movement lag.zip

@AThousandShips
Copy link
Member

@phantomdesvin
Copy link
Author

I tried the workarround sugested in related issues, calling force_update_scroll(). It fixes the problem using lerp, but it doesn't fix the problem using tweens.

@AThousandShips
Copy link
Member

That's probably because tweens fire at the end of the frame, try using a method tweener that combines the update with sending this signal

@phantomdesvin
Copy link
Author

That's probably because tweens fire at the end of the frame, try using a method tweener that combines the update with sending this signal

Can you explain how could I do that? I'm a begginer and I don't know what do you mean by combining the update.

@AThousandShips
Copy link
Member

AThousandShips commented Jun 4, 2023

See here and do the position update and the force_update_scroll() in the method

@phantomdesvin
Copy link
Author

See here and do the position update and the force_update_scroll() in the method

Thank you, it worked.

@Calinou
Copy link
Member

Calinou commented Jun 5, 2023

Thanks for the report! Consolidating with #74203.

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

Successfully merging a pull request may close this issue.

3 participants