I'm working on a targeting system that's very close to working perfectly, but I've run into one snag. When my trigger attempts to set a target variable to the enemy unit closest to my hero unit within a circular region that's following the hero through other triggers, it always sets the target variable to the enemy unit closest to the bottom of the circle instead of the one closest to the hero. Can anyone help me adjust this so it picks up the unit closest to the hero instead?
Here's the action trigger that's trying to set the target variable:
Variable - Set P1's target = (Closest unit to (Position of Heroes[1]) in (Any units in Player 1 tracker zone owned by player 15 matching Excluded: Player, Ally, Neutral, Missile, Dead, Hidden, with at most 1))
Edit: I replaced the trigger moving the region to follow the hero with one that simply attached the region to the hero. The trigger still fails to locate the actual closest unit to the hero, though.
So If I'm understanding you correctly, your problem is that it takes the closest unit to your hero with the consideration that Z = 0, (x,y,0)? There is a set point height function, you could then use arithmetic and use the function height of unit divide 2.
Point - Set the height of Point to ((Height of (Triggering unit)) / 2.0)
Hm, I'm not sure I'm following what your advice is. Is the advice to create a point, create the trigger that sets it to that height, then create a trigger that searches for units from there?
If it helps, I've attached some pictures from my test map.
The first screenshot shoes the full trigger in the editor. (I'm using the hotkey for stimpack to activate the trigger.)
The "goal" picture shows what I'd like it to do 100% of the time. (Player is locked onto nearest p15 unit as target unit, which is then outlined in a white halo.)
"What I'm getting" shows what's happening instead, where a distant pursuing zergling is being targeted instead of the nearest one. (As seen by white halo.)
Invalid Image
Oh you know what your problem might be, is that you set your action to "with at most 1". So this is only looking at a unit group of size 1 and picking which one of that one unit is closest. You should set it to any so that it takes all the units in that region then picks which one of them is closest.
I'm working on a targeting system that's very close to working perfectly, but I've run into one snag. When my trigger attempts to set a target variable to the enemy unit closest to my hero unit within a circular region that's following the hero through other triggers, it always sets the target variable to the enemy unit closest to the bottom of the circle instead of the one closest to the hero. Can anyone help me adjust this so it picks up the unit closest to the hero instead?
Here's the action trigger that's trying to set the target variable: Variable - Set P1's target = (Closest unit to (Position of Heroes[1]) in (Any units in Player 1 tracker zone owned by player 15 matching Excluded: Player, Ally, Neutral, Missile, Dead, Hidden, with at most 1))
Edit: I replaced the trigger moving the region to follow the hero with one that simply attached the region to the hero. The trigger still fails to locate the actual closest unit to the hero, though.
Thanks in advance.
So If I'm understanding you correctly, your problem is that it takes the closest unit to your hero with the consideration that Z = 0, (x,y,0)? There is a set point height function, you could then use arithmetic and use the function height of unit divide 2.
Point - Set the height of Point to ((Height of (Triggering unit)) / 2.0)
@MaskedImposter: Go
Hm, I'm not sure I'm following what your advice is. Is the advice to create a point, create the trigger that sets it to that height, then create a trigger that searches for units from there?
If it helps, I've attached some pictures from my test map.
The first screenshot shoes the full trigger in the editor. (I'm using the hotkey for stimpack to activate the trigger.) The "goal" picture shows what I'd like it to do 100% of the time. (Player is locked onto nearest p15 unit as target unit, which is then outlined in a white halo.) "What I'm getting" shows what's happening instead, where a distant pursuing zergling is being targeted instead of the nearest one. (As seen by white halo.) Invalid Image
Oh you know what your problem might be, is that you set your action to "with at most 1". So this is only looking at a unit group of size 1 and picking which one of that one unit is closest. You should set it to any so that it takes all the units in that region then picks which one of them is closest.
@MaskedImposter: Go
That did the trick! Thank you for your help.