Difference Between SetUnitPosition And SetUnitWhatever?

Frosthowl

TH.net Regular
Reaction score
15
Hello, can someone outline all differences between the SetUnitX/Y and the SetUnitPosition functions when dealing with movement? Thanks.
 

monoVertex

I'm back!
Reaction score
460
SetUnitX/Y uses integers as arguments (the X and Y coordinates in a Cartesian axis system) while SetUnitPosition uses a point, if I'm not mistaken (that means a handle).
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
SetUnitX/Y does not interfere with the moved unit's orders, while SetUnitPosition will cancel any current order when moved.
 

Frosthowl

TH.net Regular
Reaction score
15
I heard that setunitx/y is smoother, but it will ignore doodads while setunitposition does not...is this true?

And smith, thanks for trying, but I already knew that...which is why I added the "when dealing with movement"

+rep larcenist
 

Azlier

Old World Ghost
Reaction score
461
Yes, SetUnitX/Y ignores pathing. It can also go off of the map and crash the game. Despite this, it's still better.
 

Builder Bob

Live free or don't
Reaction score
249
As far as I know there is only one single difference between them.

SetUnitPosition() moves the unit, and then orders it to stop. A stop event even fires from SetUnitPosition. SetUnitX/Y does not issue any orders to the moved unit.

Issuing an order to a unit will make the game attempt to move all units within collision range to a free spot. It's the same for all orders. This is why it looks like SetUnitPosition checks for pathing when moving the unit. If you use SetUnitPosition to move a unit far inside a forest, it will still be stuck there if a vacant location cannot be found nearby.
 

xxxtrickyxxx

(o Y o)
Reaction score
64
you can just add a collision check into the function which is really easy to do or a collision function that gets called before it is moved. i would not recommend ever moving a unit periodically using locations. using x and y coordinates requires less processing and also no locations having to be created and destroyed.
 

Viikuna

No Marlo no game.
Reaction score
265
SetUnitX + SetUnitY is also many times faster than SetUnitPosition
 
General chit-chat
Help Users

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top