• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[Trigger] SetUnitX/Y not working

Status
Not open for further replies.
Greetings everyone

I'm fairly confident with custom scripts and used them for a very long time without problem. However I encountered a strange situation where this function simply does nothing :(.

Read full source code or download map in link: Meat Hook

In the loop trigger under ---CURVE--- is the following piece of code:

  • For each (Integer Temp_IntB) from 2 to MeatHLength[MeatHCustomValue], do (Actions)
    • Loop - Actions
      • -------- CURVE --------
      • Set MeatHCurPoint = (Position of MeatHChain[Temp_IntB])
      • Set MeatHNextPoint = (Position of MeatHChain[(Temp_IntB - 1)])
      • Set Temp_Real = (Angle from MeatHNextPoint to MeatHCurPoint)
      • Set MeatHNewPoint = (MeatHNextPoint offset by MeatHChainRate[MeatHCustomValue] towards Temp_Real degrees)
      • Custom script: call SetUnitPosition(udg_MeatHChain[udg_Temp_IntB], GetLocationX(udg_MeatHNewPoint), GetLocationY(udg_MeatHNewPoint))
      • Custom script: call SetUnitFacing(udg_MeatHChain[udg_Temp_IntB], udg_Temp_Real)
      • Custom script: call RemoveLocation(udg_MeatHCurPoint)
      • Custom script: call RemoveLocation(udg_MeatHNextPoint)
      • Custom script: call RemoveLocation(udg_MeatHNewPoint)


If you replace Custom script:
  • call SetUnitPosition(udg_MeatHChain[udg_Temp_IntB], GetLocationX(udg_MeatHNewPoint), GetLocationY(udg_MeatHNewPoint))
with
  • Custom script: call SetUnitX(udg_MeatHChain[udg_Temp_IntB], GetLocationX(udg_MeatHNewPoint))
(and Y version) then it simply does nothing... but why?

Thank you for helping
 
First of all, make sure that "MeatHNewPoint" is returned successfully (That it exists and is a new point)

then Store X and Y coordinates as Arrayless variables, then use your script like this :

X/Y positioning
  • Actions
    • Set MeatHNewPoint = (MeatHNextPoint offset by MeatHChainRate[MeatHCustomValue] towards Temp_Real degrees)
    • Set MeatHNewPointX = (X of MeatHNewPoint)
    • Set MeatHNewPointY = (Y of MeatHNewPoint)
    • Custom script: call SetUnitX(udg_MeatHChain[udg_Temp_IntB], udg_MeatHNewPointX)
    • Custom script: call SetUnitY(udg_MeatHChain[udg_Temp_IntB], udg_MeatHNewPointY)
 
Surprisingly that work. Thank you johnysone :). I just don't understand why we can't do that in 1 function. Anyway I applied your suggestion on the head:

  • -------- <<<FORWARD>>> --------
  • Set MeatHCurPoint = (Position of MeatHHead)
  • Set MeatHNewPoint = (MeatHCurPoint offset by MeatHSpeed[MeatHCustomValue] towards (Facing of MeatHHead) degrees)
  • Set MeatHNewPointX = (X of MeatHNewPoint)
  • Set MeatHNewPointY = (Y of MeatHNewPoint)
  • Custom script: call SetUnitX(udg_MeatHHead, udg_MeatHNewPointX)
  • Custom script: call SetUnitY(udg_MeatHHead, udg_MeatHNewPointY)
  • Custom script: call SetUnitPosition(udg_MeatHHead, GetLocationX(udg_MeatHNewPoint), GetLocationY(udg_MeatHNewPoint))
  • Custom script: call RemoveLocation(udg_MeatHCurPoint)
  • Custom script: call RemoveLocation(udg_MeatHNewPoint)


the old SetUnitPosition() does the job but your method doesn't work here as it did in the first problem. Do you know why?

SOLVED: SetUnitX/Y doesn't work on units that has 0 movement speed

+rep
 
Last edited:
Status
Not open for further replies.
Back
Top