Making a enemy run from the player when looked at

My godot version is 4

I’m making a horror game and the main function is that the monster runs away when looked at. I’m a begginer in the gdscript and couldn’t find a tutorial for this in the web.

Use a raycast…

1 Like

Look into the VisibleOnScreenNotifier3D class. It emits signals when it enters or exits the screen, and you can check its is_on_screen() function at any time.

Just make sure its AABB is right for your enemy.

1 Like

But I don’t know how.

Godot has a raycast node you can attach to your player’s camera. When it intersects with relevant objects, it will emit a signal you can handle.