Hi, I dont have a specific problem. Instead, I was noticing that I had to use a bunch of workarounds recently dealing with the mouse object and Im suspecting that Im following some bad programming practices. Hopefully someone can help me improve.
Im working on a tower defence game, specifically on the UI for building and upgrading towers. My problem is that Im running a lot into situations where the order of events matters or events are running at the same time, sabotaging each other. For example:
Event 1: Triggers on mouse click, opens a menu and should only trigger when the game does not display a menu (e.g. some variable "menu"=false)
Event 2: Also triggers on mouse click, does something in the menu and should only trigger when the menu is open
So, in this case, if the menu is closed and the player clicks: Event 1 opens the menu and sets the Menu variable to true, but then the conditions for Event 2 are immediately fulfilled and Event 2 is triggered at the same time / by the same click.
I know a bunch of ways to avoid this problem like "wait for previous actions to complete", having a timer, a wait, using a intermediate state for the menu variable and probably some more. But what is the general best practice for this? My solutions always seem kind of clunky to me.
Thank you very much in advance!