Fnaf door enemy AI and jumpscare

I made a fucntional door that you can close and open and i would need something like
at random time spawn the enemy
then it would choose 1 of 2 things
flashlight the light = dead closing the door = make enemy dissapear
and the other one would be the exact oposite
and if dead = play jumpscare animation
if someone knows please i would really apperaciate it
and i could learn from it to use it for my other AI

1 Like

I am new to this as well but I would imagine it like

extend #what ever the base node
@onready Var enemy1movetimer = randi_range(Min,Max)


func _ready()
	pass
func _process():
	enemy1move()

var enemy1state = 0

func enemy1move
	if enemy1movetimer == 0 and enemy1state == 0:
		enemy1.show() or move it until position
		#the one below is to represent if it active just to stop moving or showing it whilst it already in place.
		enemy1state = 1
	ifse enermy1movetimer <= 0 and enemy1state ==0:
		enemy1movetimer = movetoward(enemy1movetimer, 0, delta)

that should be a somewhat decent start, there is the timer node but I just discovered the method above