VisibilityNotifier2D in Godot 4: it is VisibleOnScreenNotifier2D now
By Eduardo Orellana · Updated
VisibilityNotifier2D is called VisibleOnScreenNotifier2D in Godot 4, and VisibilityNotifier is VisibleOnScreenNotifier3D. In a Godot 4 project, VisibilityNotifier2D.new() fails to parse with Identifier "VisibilityNotifier2D" not declared in the current scope. Did you mean to use "VisibleOnScreenNotifier2D"?.
AppImage, x86_64. Ubuntu 22.04, Debian 12, Fedora 39 or newer.
Intel or AMD Chromebook, with Linux turned on.
What Godot is checking
GDScript resolves every name when the script loads. VisibilityNotifier2D is not a class in Godot 4, so the analyzer stops before anything runs, and because the name is in Godot's own table of Godot 3 renames, the message names the replacement.
The converter carries VisibilityNotifier2D to VisibleOnScreenNotifier2D. Its screen_entered and screen_exited signals keep their names, is_on_screen() reports whether it is visible, and rect sets the area it watches. The usual use is freeing a bullet when it leaves the screen.
Reproduce it
A Godot 3 script that creates a VisibilityNotifier2D in code, in a Godot 4 project.
extends Node
func _ready():
var notifier = VisibilityNotifier2D.new()
print(notifier)
What Godot 4.7.2 prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
SCRIPT ERROR: Parse Error: Identifier "VisibilityNotifier2D" not declared in the current scope. Did you mean to use "VisibleOnScreenNotifier2D"?
at: GDScript::reload (res://answers/visibilitynotifier2d-in-godot-4/repro.gd:4)
ERROR: Failed to load script "res://answers/visibilitynotifier2d-in-godot-4/repro.gd" with error "Parse error".
at: load (modules/gdscript/gdscript_resource_format.cpp:46)Fix it
A notifier that frees its parent when it leaves the screen.
extends Node2D
func _ready() -> void:
var notifier := VisibleOnScreenNotifier2D.new()
notifier.rect = Rect2(-8, -8, 16, 16)
add_child(notifier)
notifier.screen_exited.connect(queue_free)
print(notifier.get_class(), " rect ", notifier.rect, ", on screen: ", notifier.is_on_screen())
What the fixed script prints
Godot Engine v4.7.2.stable.mono.official.ed1daf0bf - https://godotengine.org
VisibleOnScreenNotifier2D rect [P: (-8.0, -8.0), S: (16.0, 16.0)], on screen: falseVerified on Godot 4.7.2
Both scripts on this page were run headless on Godot 4.7.2 (4.7.2.stable.mono.official.ed1daf0bf) on 18 October 2026, and the output above is what Godot printed, unedited.
Where the check lives in Godot's source: [gdscript_analyzer.cpp line 4687, the message with its hint](https://github.com/godotengine/godot/blob/4.7.2-stable/modules/gdscript/gdscript_analyzer.cpp#L4687), [renames_map_3_to_4.cpp line 1625, VisibilityNotifier2D to VisibleOnScreenNotifier2D](https://github.com/godotengine/godot/blob/4.7.2-stable/editor/project_upgrade/renames_map_3_to_4.cpp#L1625), [VisibleOnScreenNotifier2D class reference](https://github.com/godotengine/godot/blob/4.7.2-stable/doc/classes/VisibleOnScreenNotifier2D.xml).
Questions
- What replaced VisibilityEnabler2D?
- VisibleOnScreenEnabler2D, which turns a target node's processing on and off as it enters and leaves the screen.
- Why is is_on_screen() false in _ready()?
- It is updated when the frame is drawn, so it reads false until the first frame has rendered.
Related
- Particles2D in Godot 4: it is GPUParticles2D now
- Sprite in Godot 4: it is Sprite2D now
- Every verified Godot 4 answer
- VisibilityEnabler2D in Godot 4: it is VisibleOnScreenEnabler2D now
- Area in Godot 4: it is Area3D now
- Function "…()" not found in base self in Godot 4
- Identifier "…" not declared in the current scope in Godot 4
- WindowDialog in Godot 4: it is Window now
Flockbay's agent reads Godot's debugger output and fixes errors like this one in your project, on the official Godot.
Download Flockbay free