Hi y’all! I’m trying to figure out how to go about this, I know there’s a way to do this with signals but I’m having a hard time figuring this out. I want to be able to “attack” the “enemy” when the squares turn red and I click on it : 12.10.2024_14.23.12_REC . this should also “destroy” a certain amount of the “enemy’s” tail (These are created upon move, so they are stored in an array of enemy tails)
Can someone kindly point me in the right direction as to how I can go about doing this?
Yeah, so a little of both, I want to figure out how I can get player to detect if the enemy is within the red squares, these are only sprites, and also to be able to click on the enemy when it is within the red square. For now I’d like to focus on that, I think I have an idea on how to implement the logic to delete the enemy. If you need to see my code structure let me know! Thanks for replying!
Code structure is always helpful, along with scene tree.
I would set up area2Ds and check if they have been clicked.
The other way to do it is to get the mouse position with get_global_mouse_position() and get the bounding box of the enemies to check if the mouse is within the enemy’s bounding box. Then, check for a click with _input() or Input.is_action_pressed().
As for deleting the enemies, when creating the enemies, connect a signal take_damage or something similar that finds the pieces of tail on the end and removes them. If you just want to delete the enemy, just call queue_free() on it.
I don’t currently have access to my project (at work) but I can link my project on github if you’d like. I’ll try to show more when I get home. GitHub - batgnome/MainGame