• 🏆 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] Problem when Moving units

Level 21
Joined
Apr 8, 2017
Messages
1,530
Hi, im trying to make my own version of the "Sphere" from Bloodmage but with triggers

Trigger, EVERY 0.02 seconds btw
  • Acciones
    • Set zzzDruPriVisualLocBase = ((Position of zzzDruPriVisualUnit[100]) offset by (15.00, 0.00))
    • Set zzzDruPriVisualValue[1] = 1.00
    • Set zzzDruPriVisualAng = (zzzDruPriVisualAng + zzzDruPriVisualValue[1])
    • Set zzzDruPriVisualValue[2] = 50.00
    • -------- --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • if: Conditions
        • zzzDruPriVisualAng Mayor que o igual a 360.00
      • then: Actions
        • Set zzzDruPriVisualAng = (zzzDruPriVisualAng - 360.00)
      • Otros: Actions
    • Set zzzDruPriVisualLoc1 = (zzzDruPriVisualLocBase offset by zzzDruPriVisualValue[2] towards zzzDruPriVisualAng degrees)
    • Unit - Move zzzDruPriVisualUnit[1] instantly to zzzDruPriVisualLoc1, facing 90.00 degrees
    • -------- --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • if: Conditions
        • zzzDruPriVisualAng Mayor que o igual a 360.00
      • then: Actions
        • Set zzzDruPriVisualAng = (zzzDruPriVisualAng - 360.00)
      • other: Actions
    • Set zzzDruPriVisualLoc2 = (zzzDruPriVisualLocBase offset by zzzDruPriVisualValue[2] towards zzzDruPriVisualAng degrees)
    • Set zzzDruPriVisualAng = (zzzDruPriVisualAng + 120.00)
    • Unit - Move zzzDruPriVisualUnit[2] instantly to zzzDruPriVisualLoc2, facing 90.00 degrees
    • -------- --------
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • if: Conditions
        • zzzDruPriVisualAng Mayor que o igual a 360.00
      • then: Actions
        • Set zzzDruPriVisualAng = (zzzDruPriVisualAng - 360.00)
      • other: Actions
    • Set zzzDruPriVisualLoc3 = (zzzDruPriVisualLocBase offset by zzzDruPriVisualValue[2] towards zzzDruPriVisualAng degrees)
    • Set zzzDruPriVisualAng = (zzzDruPriVisualAng + 120.00)
    • Unit - Move zzzDruPriVisualUnit[3] instantly to zzzDruPriVisualLoc3, facing 90.00 degrees
    • -------- --------
    • -------- --------
    • Custom script: call RemoveLocation(udg_zzzDruPriVisualLoc1)
    • Custom script: call RemoveLocation(udg_zzzDruPriVisualLoc2)
    • Custom script: call RemoveLocation(udg_zzzDruPriVisualLoc3)
    • Custom script: call RemoveLocation(udg_zzzDruPriVisualLocBase)

The problem is that the units has a weird effect that its like a "twinkle"

ezgif-2-e0da293ce5.gif


.
 
Level 39
Joined
Feb 27, 2007
Messages
5,016
Two of them are being moved to the same location, and the unused location precesses around every 3 cycles, so 0.06s. I expect that’s the issue. You change the angle after moving #2 instead of increasing the angle right after you move #1. What you did from 2->3 is correct, you just messed up 1->2.

There should be no need to check the angle >=360 between each unit; the game knows how to handle 495 degrees or whatever. Just do the check once, or better: use the Modulo function, which gives the remainder when dividing by a number. 402 mod 360 is 42, the leftover after taking away 360. This works no matter how many multiples of 360 higher the angle variable is; it will always reduce to < 360.
 
Level 21
Joined
Apr 8, 2017
Messages
1,530
Two of them are being moved to the same location, and the unused location precesses around every 3 cycles, so 0.06s. I expect that’s the issue. You change the angle after moving #2 instead of increasing the angle right after you move #1. What you did from 2->3 is correct, you just messed up 1->2.

There should be no need to check the angle >=360 between each unit; the game knows how to handle 495 degrees or whatever. Just do the check once, or better: use the Modulo function, which gives the remainder when dividing by a number. 402 mod 360 is 42, the leftover after taking away 360. This works no matter how many multiples of 360 higher the angle variable is; it will always reduce to < 360.
Well, it works for me, it made me do some fixes, tyvm 😘
 
Top