• 🏆 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] Arrow key movement . . . anyone?

Status
Not open for further replies.
Level 18
Joined
Aug 23, 2008
Messages
2,319
  • Up key movement
    • Events
      • Player - Player 1 (Red) Presses the Up Arrow key
    • Conditions
    • Actions
      • Unit - Order <YOUR UNIT> to Move To ((Position of <YOUR UNIT>) offset by (0.00, 10.00))
  • Down key movement
    • Events
      • Player - Player 1 (Red) Presses the Down Arrow key
    • Conditions
    • Actions
      • Unit - Order <YOUR UNIT> to Move To ((Position of <YOUR UNIT>) offset by (0.00, -10.00))
  • Left key movement
    • Events
      • Player - Player 1 (Red) Presses the Left Arrow key
    • Conditions
    • Actions
      • Unit - Order <YOUR UNIT> to Move To ((Position of <YOUR UNIT>) offset by (-10.00, 0.00))
  • Right movement
    • Events
      • Player - Player 1 (Red) Presses the Right Arrow key
    • Conditions
    • Actions
      • Unit - Order <YOUR UNIT> to Move To ((Position of <YOUR UNIT>) offset by (10.00, 0.00))
I think this should do it. However, the movement 'Up movement' will cause the unit to go to the north part of the map, not towards the point where the unit is facing. Same with Left makes him go to the east, Down to the south and Right to the west.

If this causes the 'Move' animation to repeat only the first 1/10th of a second of the animation, you have to increase the offsets from 10 to something big enough to play the whole animation (e.g. 500). This will cause the unit to go 500 further. To make him stop when you release the arrow key, add this trigger for each arrow key:
  • Stop Up key movement
    • Events
      • Player - Player 1 (Red) Releases the Up Arrow key
    • Conditions
    • Actions
      • Unit - Order No unit to Stop
 
Level 21
Joined
Aug 21, 2005
Messages
3,699
I think (but not sure) that the "Presses key" event only happens once, and not periodically, until the key is released. Therefor, to make you move as long as a key is pressed, you'll have to do something like:

  • Events
    • Player - Player 1 presses the Right Arrow Key
  • Actions
    • Set RightArrow = true
  • Events
    • Player - Player 1 releases the Right Arrow Key
  • Actions
    • Set RightArrow = false
  • Events
    • Every 0.2 seconds of game time
  • Conditions
    • RightArrow = true
  • Actions
    • Set TempPoint1 = Position of <YOUR UNIT>
    • Set TempPoint2 = (TempPoint1 offset by (10.00, 0.00))
    • Custom script: call RemoveLocation(udg_TempPoint1)
    • Unit - Order <YOUR UNIT> to Move To TempPoint2
    • Custom script: call RemoveLocation(udg_TempPoint1)
 
Level 18
Joined
Aug 3, 2008
Messages
1,935
your warm.

you dont have a stop trigger. And if you press one of the keys, you will move in baby steps.\

edit : here are mine

  • Polar MoveForward
    • Events
      • Player - Player 1 (Red) Presses the Up Arrow key
    • Conditions
    • Actions
      • Set PolarMove_Forward = True
      • Unit - Order Footman 0000 <gen> to Move To ((Position of Footman 0000 <gen>) offset by 100.00 towards PolarMove_Angle degrees)
      • Wait 0.01 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PolarMove_Forward Equal to True
        • Then - Actions
          • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
          • Do nothing
  • Polar MoveForwardStop
    • Events
      • Player - Player 1 (Red) Releases the Up Arrow key
    • Conditions
    • Actions
      • Unit - Order Footman 0000 <gen> to Hold Position
      • Set PolarMove_Forward = False
  • Polar TurnLeft
    • Events
      • Player - Player 1 (Red) Presses the Left Arrow key
    • Conditions
    • Actions
      • Set PolarMove_TurnLeft = True
      • Set PolarMove_Angle = (PolarMove_Angle + 10.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PolarMove_Forward Equal to True
        • Then - Actions
          • Do nothing
        • Else - Actions
          • Unit - Make Footman 0000 <gen> face PolarMove_Angle over 0.25 seconds
      • Wait 0.25 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PolarMove_TurnLeft Equal to True
        • Then - Actions
          • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
          • Do nothing
  • Polar TurnLeftStop
    • Events
      • Player - Player 1 (Red) Releases the Left Arrow key
    • Conditions
    • Actions
      • Set PolarMove_TurnLeft = False
***** Turn Left is the same as turn right except that Polar move angle is equal to -10 instead of +10.


  • Polar Reverse
    • Events
      • Player - Player 1 (Red) Presses the Down Arrow key
    • Conditions
    • Actions
      • Set PolarMove_Angle = (PolarMove_Angle + 180.00)
  • Polar FixAngle
    • Events
      • Game - PolarMove_Angle becomes Greater than 360.00
    • Conditions
    • Actions
      • Set PolarMove_Angle = 0.00
  • Polar FixAngle2
    • Events
      • Game - PolarMove_Angle becomes Less than 0.00
    • Conditions
    • Actions
      • Set PolarMove_Angle = 360.00
_________________________________________________________________


The fix angles are so that he wouldn't spin in random directions ( Angles might get messed up.



By the way, i know there are some leaks in here ( Didn't clean up any points or what not.
 
Level 5
Joined
Oct 17, 2006
Messages
151
your warm.

you dont have a stop trigger. And if you press one of the keys, you will move in baby steps.\

edit : here are mine

  • Polar MoveForward
    • Events
      • Player - Player 1 (Red) Presses the Up Arrow key
    • Conditions
    • Actions
      • Set PolarMove_Forward = True
      • Unit - Order Footman 0000 <gen> to Move To ((Position of Footman 0000 <gen>) offset by 100.00 towards PolarMove_Angle degrees)
      • Wait 0.01 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PolarMove_Forward Equal to True
        • Then - Actions
          • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
          • Do nothing
  • Polar MoveForwardStop
    • Events
      • Player - Player 1 (Red) Releases the Up Arrow key
    • Conditions
    • Actions
      • Unit - Order Footman 0000 <gen> to Hold Position
      • Set PolarMove_Forward = False
  • Polar TurnLeft
    • Events
      • Player - Player 1 (Red) Presses the Left Arrow key
    • Conditions
    • Actions
      • Set PolarMove_TurnLeft = True
      • Set PolarMove_Angle = (PolarMove_Angle + 10.00)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PolarMove_Forward Equal to True
        • Then - Actions
          • Do nothing
        • Else - Actions
          • Unit - Make Footman 0000 <gen> face PolarMove_Angle over 0.25 seconds
      • Wait 0.25 seconds
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • PolarMove_TurnLeft Equal to True
        • Then - Actions
          • Trigger - Run (This trigger) (checking conditions)
        • Else - Actions
          • Do nothing
  • Polar TurnLeftStop
    • Events
      • Player - Player 1 (Red) Releases the Left Arrow key
    • Conditions
    • Actions
      • Set PolarMove_TurnLeft = False
***** Turn Left is the same as turn right except that Polar move angle is equal to -10 instead of +10.


  • Polar Reverse
    • Events
      • Player - Player 1 (Red) Presses the Down Arrow key
    • Conditions
    • Actions
      • Set PolarMove_Angle = (PolarMove_Angle + 180.00)
  • Polar FixAngle
    • Events
      • Game - PolarMove_Angle becomes Greater than 360.00
    • Conditions
    • Actions
      • Set PolarMove_Angle = 0.00
  • Polar FixAngle2
    • Events
      • Game - PolarMove_Angle becomes Less than 0.00
    • Conditions
    • Actions
      • Set PolarMove_Angle = 360.00
_________________________________________________________________


The fix angles are so that he wouldn't spin in random directions ( Angles might get messed up.



By the way, i know there are some leaks in here ( Didn't clean up any points or what not.

so does this like not work then?

And do you want your person to move only up left right down or 2 at a time?
 
Status
Not open for further replies.
Top