So, I’m making this top-down rpg game
and I’m creating the first enemy.
Wich will be this little slime that wonders around, and whenever I try to attack and I’m too close, it changes his behaviour and begins to follow me until I’m closer, and when I’m close enough he rushes towards the player and damages him.
So my problem is that, whenever I add more then 1 enemy, the “taunt” and “attack” behaviours don’t work. But when there’s only 1 enemy, it works fine.
Unfortunately, trigger once doesn’t work as you might expect within “for each” events. It behaves the same as it does outside of “For each”, meaning that it only occurs once then never again until the conditions are false.
This means that it only occurs on the first enemy instance, so all of the other enemy instances don’t have it.
You’ll need to create some other kind of tracking variable to use to decide whether those items should occur only once or not.
For your taunt, your option is pretty easy: Just set Taunt of Blobby = False after it sets attacking to true.
For attacking, you probably need to add some sort of “AttackTimerStarted” variable, then as a subevent of your “Attacking = True” event, have it check “AttackTimerStarted = False”, start/reset the timer and change the animation, and set that same variable to true, so it doesn’t keep restarting the timer.