Hey i’m looking for a way to make a player select an enemy in something like a turn-based rpg. to be specific, so far i have set up a command menu using UI elemenets and would like to know how to give a player a chance to select an enemy after clicking “attack” for example, so far i have tried using “await” but i’ll be honest i don’t really understand it, as well as a “while loop” and a “recersive call function” both of the latter resolting in the game crashing. Any help if apprciated + sorry for bad english.
If everything is made of controls, you can check for clicks via _gui_input(). If it’s made of other nodes, you can check via _input() or _unhandled_input().
After the player selects an attack, you can set a boolean such as _choosing_enemy. While the condition is true, you allow the enemy nodes to accept mouse clicks, and send a signal when one is clicked (for example). Once the signal is received, _choosing_enemy is now false, and you perform whatever you need on said enemy.
I don’t see how await or while loops would help you achieve your goal here, so leave them aside for now.
It would be best if you showed us how you attempted doing it by pasting the code (as preformatted text between the three backticks ```), and showing some screenshots, then we can see how best to solve your issue.
thank for the input just to clearify the enemies are not UI elemets they are a class that extends Area2D, i will try what you are suggesting however it will require a code overhaul so give me sometime