0 votes

I am having a little trouble with the VisibilityNotifier2D node.

I have a game that I'm testing in a window, and I'm simply trying to detect when an object is going out of the visible window space. I have first connected the screen_entered and the screen_exited signals, and then the viewport_entered and the viewport_exited signals to a function printing either "enter" or "exit".
While the *_entered signals are emitted right when the node enters the window, the *_exited signals however are not getting emitted immediately after the node exits the window. As long as it's not "far enough", so to speak, outside the window, they don't seem to be emitted.

So if the node just stops there and doesn't move, then it can be entirely outside of the window but never emit the *_exited signals.

Is this a bug ? Or am I doing something wrong ?
I am using Godot 3.0.2 stable from Steam if that's of any relevance.

in Engine by (15 points)

1 Answer

0 votes
Best answer

That's the way it's designed. It was a choice between speed and accuracy, and they chose speed.

This makes sense, since most people probably use it to have nodes remove themselves without having to know the window or screen boundaries, especially in shooter-style games with a lot of objects onscreen at once.

If you want to be more precise, you'll probably want to add Area2Ds or similar colliders to your window boundaries.

by (84 points)
selected by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.