This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

So, in a game, I'm implementing enemies, as a lot of games do, as KinematicBody2Ds. For the most part, everything has been going well, but there's one problem: the enemies will still do all they'd normally do, even if they're offscreen. This is of course problematic for two reasons:

  • There's no reason in trying to run a bunch of code when offscreen
  • For example, if the enemy is programmed to walk forward no matter what, they might fall off a ledge before the player even reaches them, and other things like that

So, how could I just make the enemies not do anything when offscreen?

in Engine by (68 points)

1 Answer

+1 vote
Best answer

You can use a VisibilityNotifier2D to let you know when the enemy is/isn't on screen.

by (22,191 points)
selected by

Oh, right. I forgot about that node. Thanks!

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 Frequently asked questions and 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 [email protected] with your username.