I had made the mistake of trying to use a static variable for something in the RPG course with SO’s. Does the same thing apply here? Do these SM’s share the same instance or something?
The reason I ask is I am making a Taunt state for the enemies. I want them to taunt X number of times when the player dies and then return to the idle state. So I have my checks where we set the idle state for the player death here. So I would set a static int to keep track of the taunts performed and once it reaches a certain point I just release them back to the Idle state as usual and the next passby on checking if the player is in chase range I return false.
The problem I have found is that if two enemies down me either both enemies taunt me once each or one of them sneaks in two taunts while the other is finishing an attack animation. I assume the only explanation for this is what I feared… Shared script instance. I’ve tried having the static in the BaseState (where BOTH my chase range and attack range checks are… I like the attack check there rather than in chasing in case I want to do a ranged enemy that fires WITHOUT chasing). I’ve also tried putting the static in the EnemyStateMachine as a public.
I’m also sure you’ll tell me an easier way to do this. I suppose in my Taunt state I can just calculate the clip size times the amount of taunts I want and decrement timer in Tick that exits when it should be done. Just seemed more straightforward to do it this way, especially since I’d like to be able to use the Taunt state just for random taunts from enemies in other situations.