Cant get script working properly - fnaf ai

Godot Version

3.5

Question

I am programming a fnaf fan game, but i cant get the ai working. Am i doing something wrong? please help!

Blockquote
func _physics_process(delta):
$Timer.start()
if $Timer.stop():
move = rng.randi_range(1,1)
if move == 1 and indatcam == 1:
incam(2)
print(“MOVED TO 2”)
return
elif move == 1 and indatcam == 2:
incam(3)
print(“MOVED TO 3”)
return
elif move == 1 and indatcam == 3:
incam(4)
print(“MOVE TO 4”)
return
elif move == 1 and indatcam == 4:
incam(5)
return
elif move == 1 and indatcam == 5:
incam(6)
else:
return

By the looks of it, you want your code to run when the timer runs out. Calling “$Timer.stop()” won’t achieve this. You’ll want to connect the “.timeout()” property of the timer to the script using a signal and put your code in the function it creates.

What @Shoompla said.

Also, _physics_process gets called 60 times per second. Do you really want to be starting a timer 60 times per second? Perhaps you meant to start the timer in a different place, like _ready().

Yes, thank you so much!

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.