- Home /
Does Event fire only once during Update()?
Hello everyone,
I'm currently working on a Tactical turn-based RPG on Unity. I made the mistake (I guess?) to switch the state in the Update() function. It kinda looks like this:
void Update() {
switch (state) {
case State.IDLE:
/// Do this
case State.MOVING:
/// Do this
case State.TURN:
/// Do this
}
}
Now I'm implementing the monster IA, I'm facing an issue that, for example, when they're in State TURN, they are able to attack multiple times at once (sometimes 2, sometimes 3 when they should only attack once). I guess this is because of the Update() function.
I tried using a Coroutine but this doesn't work neither.
I was wondering then if I should (finally) start learning about Unity Events? Will it resolve my issue?
My goal is that when the monster begins his turn: 1) It checks for the player cell (it is grid based) 2) It moves next to the player cell 3) It attacks the player (as many times as he has enough Action Points)
Thank you very much for your help!
Kind regards