Camera2D does instantly disable custom drawing once it moves.

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

Dear community,
while working on a project for school, a problem turned out that really messed everything up. The project I’m working on is level-based. Every level (root is Node2D) has got an instance of the player scene, containing a Camera2D as a child so that the cam moves along the player. Also, there is a Control-Node which is supposed to draw the GUI. Here is the very simple script for the Control-Node:

extends Control

func _process(delta):
	update();
	pass

func _draw():
	draw_circle(get_viewport().get_mouse_position(),50,Color(0,0,0));
	pass

Basically, it draws the circle fine, until the Camera2D-Node moves. Then the circle instantly disappers. When the Camera comes back to it’s former position, the circle comes back again. The cam just temporarly disables the _draw function of the Control Node when it doesn’t like it’s position. How is that possible?

For more Info, the Camera2D-Node:

[node name="Camera2D" type="Camera2D" parent="Player"]
current = true
limit_left = 0
limit_top = 0
limit_bottom = 0
drag_margin_left = 0.0
drag_margin_top = 0.0
drag_margin_right = 0.0
drag_margin_bottom = 0.0
:bust_in_silhouette: Reply From: Dooowy.

No,
Use viewport instead of Camera2D. When the camera moves its position is not passed and results in a NULL. This does not occur in Viewport.