• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[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
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
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.
Top