Hello,
I've been working for a few hours trying to set up some simple enemy ai.
Here is what I want my enemy to do:
1. Wait for 0.5 seconds
2. Choose to move left or right for 0.5 seconds
Then I just want this to loop forever.
Tutorials I have watched have suggested giving the enemy platformer behavior, setting up an instance variable, and setting certain values of the variable to correspond to left, right, etc.
I first tried doing this (with 1 being sitting still, 2 being left, and 3 being right):
When variable is 1 > wait 0.5 second
set variable to 2 or 3
When variable is 2 > simulate left
wait 0.5 second
set variable to 1
When variable is 3 > simulate right
wait 0.5 second
set variable to 1
This would make the enemy rapidly switch between left and right at inconsistent rates. I'm not sure exactly why this happens. My best guess is that, since the variable is always 2 during the event, it resets it instead of waiting? I'm really not sure.
Thanks in advance!