This is an old revision of the document!
⇐ Index
SetUnitSpecifiedTarget(<-Unit <-pos)
Sets a unit's specified target location. The specified target is a map cell location that is set either by player interaction or by script.
The value to set is a vector consisting of three coordinates. The map position is in the X and Z locations. The Y-value/2nd vector of this V3 is ignored but still needs to “exist” so you can't use only a V2 as the 2nd vector of the V2 will be placed in the Y-vector of the V3 only to then be ignored, causing a V3 of (X Z 0). To avoid this, either use a V3 like in the example or organize a V3 like so: “V3(<-X 0 <-Z)” or “V3(<-.x 0 <-.z)”. You can not directly input a V2 into this API because of this need of organizing the stack around the Y-value vector.
The “SpecifiedTarget” only exists when the unit has “Can Specify Target” enabled in their cpack settings, found in the “Basic” tab of Settings. When a unit allows “Can Specify Target”, an opaque line or arch (specified by SetUnitSpecifiedTargetPathHeight1)) can be seen even when inside or behind terrain along with a visable gray target icon at the SpecifiedTarget location. The gray line can become invisible by using the API SetUnitSpecifiedTargetShowPath to set it to false, making only the gray line invisible (except at 0,0,0).
Both the gray line (if visible) and gray target marker will follow the mouse when selected. SpecifiedTarget is good for units that like to allow a player to specify where they should fire or, for especially flying and controllable units, move to without involving the unit ghost created by the game's built-in movement system which implies the unit is meant for the ground and not the air. The Thor is a perfect example of using SpecifiedTarget as a way for a player to control air units neatly. Just beware of how visually noisy the opaque lines can be.
SetUnitSpecifiedTarget(self V3(10 0 20))
⇐ Index