• 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.

[General] SetUnitX, SetUnitY question.

Status
Not open for further replies.
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.
Top