How he uses suffering is shown when it passes by him in Godot 4

Godot Version


How do I make the enemy appear when the player passes by him in Godot 4?

Have you already tried Area2D or Area3D as a placeholder?

Let’s say you store reference to player object in some singleton that you called Game. Then in enemy script you can:

var distance_when_to_appear := 150
var in_stealth := true

func _ready():
	# set sprite's or animated sprite's visible property to false
	# disable collision shape(s)

func _process():
	if not in_stealth:
		# do w/e logic enemy should do when visible

	if global_position.distance_to(Game.player.global_position) <= distance_when_to_appear:

func become_visible():
	in_stealth = false

	# here just set your sprite's or animated sprite's (whichever one you're using) visible property to true
	# enable collision shape(s) 

My game 3D

For 3D there are similarly named overlaps with Area and Body:

Much the same as with 2D just assign them a collision shape and set the event flags.