get_viewport_position() when camera is moving (smoothing on)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By navi2000

When I call get_viewport_position() I expect to get the position of the node in the viewport. That happens when the smoothing camera is off, but when it’s on I get the final position of the node.

Normally this is not important, but I have a node2d that’s drawing (_draw()) directly to the screen position (like a viewport size texture that needs to know exactly where the different elements in the screen are).

So, is there any way to get the real position of the sprites when the screen is moving smoothly or the only way is to set smoothing off and code my own camera 2D smoothing code?

:bust_in_silhouette: Reply From: technistguru

Use get_camera_position() on the active camera.

:bust_in_silhouette: Reply From: navi2000

Sorry for the delay: the only way to acomplish the task was using the get_camera_screen_center() function.

1 Like