• 🏆 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!

[Solved] Slide System (x and y position movement) problems

Status
Not open for further replies.

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
EDIT: I managed to solve the issues with this trigger:

  • Knight Mounted Controls
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • InterruptOrders[(Custom value of (Triggering unit))] Equal to False
      • Or - Any (Conditions) are true
        • Conditions
          • (Unit-type of (Triggering unit)) Equal to Knight (Mounted)
      • Or - Any (Conditions) are true
        • Conditions
          • (Issued order) Equal to (Order(smart))
          • (Issued order) Not equal to (Order(smart))
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Target unit of issued order) Equal to No unit
        • Then - Actions
          • Set TempPoint1 = (Target point of issued order)
        • Else - Actions
          • Set TempPoint1 = (Position of (Target unit of issued order))
      • Set TempUnit1 = (Triggering unit)
      • Set TempPlayer1 = (Owner of TempUnit1)
      • Set InterruptOrders[(Custom value of TempUnit1)] = True
      • Unit - Order TempUnit1 to Stop
      • Unit - Pause TempUnit1
      • Unit - Unpause TempUnit1
      • Unit - Make TempUnit1 face TempPoint1 over 0.00 seconds
      • Set InterruptOrders[(Custom value of TempUnit1)] = False
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • IsMoving[(Player number of TempPlayer1)] Equal to False
        • Then - Actions
          • Set IsMoving[(Player number of TempPlayer1)] = True
        • Else - Actions
      • Custom script: call RemoveLocation (udg_TempPoint1)

Hello, I'm trying to make a a simple slide system for my map that moves a unit in the direction it's facing using X and Y. I've managed to get it to work for the most part, however there are some issues I'd like to fix.

Here are the triggers:

  • Facing Example
    • Events
      • Unit - A unit Is issued an order targeting a point
      • Unit - A unit Is issued an order targeting an object
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Knight (Mounted)
    • Actions
      • Set TempUnit1 = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Target unit of issued order) Equal to No unit
        • Then - Actions
          • Set TempPoint1 = (Position of TempUnit1)
          • Set TempPoint2 = (Target point of issued order)
          • Set TempReal1 = (Angle from TempPoint1 to TempPoint2)
          • Unit - Order TempUnit1 to Stop
          • Unit - Make TempUnit1 face TempReal1 over 0.00 seconds
          • Custom script: call RemoveLocation (udg_TempPoint1)
          • Custom script: call RemoveLocation (udg_TempPoint2)
        • Else - Actions
          • Set TempPoint1 = (Position of TempUnit1)
          • Set TempPoint2 = (Position of (Target unit of issued order))
          • Set TempReal1 = (Angle from TempPoint1 to TempPoint2)
          • Unit - Order TempUnit1 to Stop
          • Unit - Make TempUnit1 face TempReal1 over 0.00 seconds
          • Custom script: call RemoveLocation (udg_TempPoint1)
          • Custom script: call RemoveLocation (udg_TempPoint2)

  • Movement Example
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • Set TempPoint1 = ((Position of TempUnit1) offset by 5.00 towards (Facing of TempUnit1) degrees)
      • Set X = (X of TempPoint1)
      • Set Y = (Y of TempPoint1)
      • Custom script: call SetUnitX( udg_TempUnit1 , udg_X )
      • Custom script: call SetUnitY( udg_TempUnit1 , udg_Y )
      • Custom script: call RemoveLocation (udg_TempPoint1)

Issues:
1) The sliding unit spins in an endless circle if you right click/order it to move too close to itself.
2) The sliding unit spins if you click near unpathable terrain, and even just being near anything with collision seems to cause the unit to spin or move erratically. I'm assuming this is because the unit attempts to path around the obstacle, while at the same time it's constantly being moved in the direction it's facing.

What I'm trying to achieve:
Keep the unit's collision ON, and allow it to sort of force it's way around obstacles. I imagine I could do this with triggers detecting pathability and adjusting the unit's angle until it finds a way around the obstacle, but I was wondering if that's even necessary? So if anyone has worked with a slide system before, how would you go about giving the unit collision that doesn't conflict with it's movement? Also, can I stop the unit from trying to path the standard way? It'd be nice to be able to keep the controls the same (using right click/move orders to make the unit face a direction) but cancel the actual order to move so the sliding unit doesn't attempt to use warcraft 3's standard pathing system.
 
Last edited:

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,564
(Position of TemUnit1) leaks.
Use Unit - Move Unit Instantly so the unit only faces and doesn't have any other orders.
Thanks, I was aware of the leak but still appreciated, and I assume you meant replace "Make unit face Angle" with "Move Unit + Face Angle/Point". That worked for the most part but my unit would still spin erratically once it got close to other units so maybe I did it wrong. Instead, I got it working with the new trigger I posted above.
 
Status
Not open for further replies.
Top