(Solved) How do i make npcs fire bullets through ai?

In my tower defiance game there are four towers each watching one region of the island. While the player is active in one of them, the other three need to work on their ai through ai, how do I achieve this?
Here is the code logic, but it isnt working:

Please help!

Here’s a project I created to help someone. It might have some helpful concepts. I was really happy with how it came out. It’s crude and needed better logic but the concept worked very efficiently. It targets the enemies (or player) using the lowest health value. Again, it needs tweaking, the targeting is going to be complex. It then creates a predicted health value so the other towers wouldn’t all fire at the same target. I decided to use a tween for the projectiles. It allowed me to target specific locations and the projectile exploded even if there wasn’t anyone there. I also linked the projectile with the target, so it would pass over unintended targets. That part could be changed to add damage to only check for collisions when the tween ended. That would eliminate the linking and allow damage to be added to anyone in the area.

For my example, click anywhere to fire all towers, everything is draggable and escape restarts it.

project:

1 Like

Thanks a lot for your help, but i found this in chatGPT which helped me figure the solution:

Conditions:
Distance between two objects(NPC, Enemy) is less than 200 pixels

1 Like