How to update VisibilityNotifier2D.is_on_screen()

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By splite
:warning: Old Version Published before Godot 3 was released.

I have 2D laser beam.

Its simple Sprite node with rotation & scale on Y and RayCast2D as child node to find hit & cut beam at hit position (via scaling on y : (collision - pos).length()).

So far everything is good and working.

But, when player get out of laser reach and laser is still firing, sayd laser is “cut” in middle of screen, which doesnt look good. Its laser, you know, one does not simply cut laser beam :slight_smile:

screenshot on google drive

So i added VisibilityNotifier2D, moving it at the end of beam (again, its only pos.Y in local space) and multiply pos.Y every time get_node("VisibilityNotifier2D").is_on_screen() returns true, like this:

# inside _process()
# variables _laser_is_colliding and _laser_colliding_at are from _fixed_process()
# variable laser_reach is how far laser beam can hit anything (also hint for AI to look for enemies max away)
# laser_ray is Sprite node and laser_hit_effect is Sprite node with some fx to hide flat laser end
if _laser_is_colliding:
			var collision_length = (_laser_colliding_at - get_global_pos()).length()
			laser_ray.set_scale(Vector2(1, collision_length))
			laser_hit_effect.set_hidden(false)
			laser_hit_effect.set_pos(Vector2(0, collision_length + 25))
		else:
			# do-while missing...
			laser_end_visible.set_pos(Vector2(0, laser_reach))
			#laser_end_visible.update() ????????????
			laser_ray.set_scale(Vector2(1, laser_reach))
			var c = 2
			while laser_end_visible.is_on_screen():
				laser_end_visible.set_pos(Vector2(0, laser_reach * c))
				#laser_end_visible.update() ????????????
				print(str('local pos: [', Vector2(0, laser_reach * c), '] global pos: [',laser_end_visible.get_global_pos(), '], is_on_screen:', laser_end_visible.is_on_screen()))
				laser_ray.set_scale(Vector2(1, laser_reach * c))
				c = c + 1
			laser_hit_effect.set_hidden(true)

But laser_end_visible.is_on_screen() is returning true forever, even when his pos is far outside possible Camera2D position (say, 10k px on both axis, still .is_on_screen() is true).

So i think, i have to call some “update” func… or… something… I am really hoping visibility tests are computed and not done as rendering some color and checking it :slight_smile: But i have no idea which func to call. I tried to peek at VisibilityNotifier2D source code, but i cant find anything.


Edited: formatting issues & typo

:bust_in_silhouette: Reply From: splite

Self answer after 3 days:

its known bug #1269.