I am working on a game in which you can direct an ally turret to fire at an enemy, by clicking on the enemy of your choice. You can play it in its current state here to observe the problem I'm going to try to describe: http://dft.ba/-Projection
If after clicking on an enemy there is more than one of the same colour in range, the turret will turn around and fire at the nearest target, regardless of whether or not this is the one you clicked on.
This persists even if I set the target mode to 'first in range' rather than 'nearest'. If I replace 'add to target' with 'acquire target' in the code, the turret no longer rotates or fires at all. This is strange to me because based on the description in the manual, 'acquire target' should do exactly the job I'm looking for: target a specific instance of an object, rather than the nearest instance in range.
There's also a second issue, which is that even though I have the turret clear all targets once it's decided it's going to shoot, it still repeat-fires until the enemy is destroyed. Logically it doesn't seem to me that this should be happening, so I must be missing some knowledge about how things are working. Help with this second issue would be appreciated, but it's the first one that I will be very very grateful for any guidance on.
.capx is here if you're very keen: download