I am working on a game with a 1D auto battler that is very similar to super auto pets, if yoy have ever played it. If you havent, you will have 6 units that have an ability, and a trigger for said ability. Your front unit then “fights” the front unit of the enemy. Triggers are things like when a unit dies, when the battle starts, when damaged, ect. These triggers are where im struggling.
I have a function that starts the battle that effectively looks like this
Start the battle:
Check units for (start of battle) trigger
Check if any units are dead
Make the front units fight
Like this, all 3 would effectively happen at the same time, which is an issue with tweens and animations. i need each line of this function to only happen after the last line has FULLY completed. Im new to programming and at an absolute loss on how to do this. I just need ideas
I know i can use Await and timers, but that has its own issues in specific corner cases, such as a long ability chain that outlasts a specific timer. currently it is the best option i can think of.
I think i am missing something with await. I tried this and the functions were still returning before being completed. For instance, say function 1 has a tween that it itself is awaiting on. When that tween is finished it deals damage to a random unit. When i was using await for those functions, function 3 would begin while the tween from function 1 was happening.
My understanding of await was that it doesnt work with all functions. Im just very confused with await and have been unable to get it to work. With that said, i fully admit that i am probobly wrong and its an error on my end somewhere. I will work on it more tonight. I appreciate the response!
technically, it shouldnt go to function3 if you have await on function1 with await on the tween finished in function1. can you confirm that (by print) the function3 triggered the moment function1 triggered?