• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

[General] SetUnitX, SetUnitY question.

Status
Not open for further replies.
When I use these functions to move an unit to the center X,Y or max X,Y of a region, the unit always appears at the bottom left of the region. When I use the GUI function "Move unit instantly to center of region" the unit appears at the center of the region correctly. Why is this happening?
 
I think you guys are right, and this happens probably because the region is on top of an Elevator with height of 3. So how do I make the unit appear correctly at the center?
Here's the code anyway:
  • North East Base Trapdoor
    • Events
      • Unit - A unit enters Region 037 go to 034 <gen>
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Destructible - Close All walls of Small Elevator (2) 2669 <gen>
      • Custom script: call SetUnitX (GetTriggerUnit(),GetRectCenterX(gg_rct_Region_034))
      • Custom script: call SetUnitY (GetTriggerUnit(),GetRectCenterY(gg_rct_Region_034))
      • Camera - Pan camera as necessary for (Owner of (Triggering unit)) to (Center of Region 034 <gen>) over 0.50 seconds
      • Wait 1.00 seconds
      • Destructible - Set height of Small Elevator (2) 2669 <gen> to 1
      • Wait 1.50 seconds
      • Destructible - Open All walls of Small Elevator (2) 2669 <gen>
 
The region does not change it's height with the elevator's height. So the rect's x/y stay the same while the height of the elevator changes, which might effect in seemlingly wrong center coordinates.
So the problem is that there is a visual divergence, because of the different Z coordinate. To fix this you don't have to work with static x/y coordinates of the rect, but instead put them into a formula which also takes the elevator's height into account. You also can try to use approximated values, if it suffices.

Maybe an easier to do, but less straight forward way to go is to use a dummy unit, which also changes it's height together with the elevator. Then you move cam to x/y of this dummy unit, which should have same x/y/z.
 
Ah, I've finally found the problem.
SetUnitX/Y does not interrupt the unit's orders, thus when the unit gets moved to the new region, it will try to move back to the point where the last right-click happened.
This gets solved with an "Order Triggering unit to Stop" action. But then it won't be different from a "Move unit instantly" action. :P
 
Status
Not open for further replies.
Back
Top