• 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 faction for Warcraft 3 and enter Hive's 19th Techtree Contest: Co-Op Commanders! Click here to enter!
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 21st Texturing Contest: Upgrade is now concluded, time to vote for your favourite set of icons! Click here to vote!

How do I use the keyboard arrows to move a character diagonally?

Status
Not open for further replies.
Level 4
Joined
Jun 22, 2009
Messages
36
Hi. So, I was just tuaght how to use the keyboard arrows. But, I want to be able tomove a character DIAGONALLY, and I'm not good with variables.:sad:
Help would be very welcome, but I need slow, careful directions PLEASE. What can I say, I'm a newbie.
 
Level 4
Joined
Jun 22, 2009
Messages
36
Ok, well, when I say I learned to use the keyboard arrows, I mean that I can now use the trigger Event: Keyboard Event (Player 1 presses the left arrow key) ACTION: Unit-Order unit to move to ((Position of Unit) offset by (-90, 0). So now, I want, when a player presses both the UP arrow and the LEFT arrow key, for the unit to move northwest.
 
Level 8
Joined
Dec 8, 2007
Messages
312
Here is simple solution. It might look big but it's only if/then/else action that makes it look big.
  • Events
    • Time - Every 0.10 seconds of game time
  • Conditions
  • Actions
    • If (Boolean_Left Equal to True) then do (Unit - Move (Triggering unit) instantly to ((Position of (Triggering unit)) offset by (-45.00, 0.00))) else do (Do nothing)
    • If (Boolean_Right Equal to True) then do (Unit - Move (Triggering unit) instantly to ((Position of (Triggering unit)) offset by (45.00, 0.00))) else do (Do nothing)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Boolean_Up Equal to True
      • Then - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Boolean_Right Equal to True
          • Then - Actions
            • Unit - Move (Triggering unit) instantly to ((Position of (Triggering unit)) offset by (45.00, 45.00))
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Boolean_Left Equal to True
              • Then - Actions
                • Unit - Move (Triggering unit) instantly to ((Position of (Triggering unit)) offset by (-45.00, 45.00))
              • Else - Actions
                • Unit - Move (Triggering unit) instantly to ((Position of (Triggering unit)) offset by (0.00, 45.00))
      • Else - Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Boolean_Down Equal to True
      • Then - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Boolean_Right Equal to True
          • Then - Actions
            • Unit - Move (Triggering unit) instantly to ((Position of (Triggering unit)) offset by (45.00, -45.00))
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Boolean_Left Equal to True
              • Then - Actions
                • Unit - Move (Triggering unit) instantly to ((Position of (Triggering unit)) offset by (-45.00, -45.00))
              • Else - Actions
                • Unit - Move (Triggering unit) instantly to ((Position of (Triggering unit)) offset by (0.00, -45.00))
      • Else - Actions

you also must have 4 button press triggers and 4 button release triggers that set Boolean variables.
  • Events
    • Player - Player 1 (Red) Presses the Up Arrow key
  • Conditions
  • Actions
    • Set Boolean_Up = True
  • Events
    • Player - Player 1 (Red) Releases the Up Arrow key
  • Conditions
  • Actions
    • Set Boolean_Up = False
  • Events
    • Player - Player 1 (Red) Presses the Left Arrow key
    • .......so on......
 
Level 11
Joined
May 31, 2008
Messages
698
I would make booleans for each keyboard event.


For the left press event (you will need a similar one for up, down, and right):
  • LeftPress
    • Events
    • Conditions
    • Actions
      • Set left[(Player number of (Triggering player))] = True
      • Set TempLoc = ((Position of (Picked unit)) offset by (200.00, 200.00))
      • Unit - Order (Picked unit) to Move To TempLoc
      • Custom script: call RemoveLocation(udg_TempLoc)
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • up[(Player number of (Triggering player))] Equal to (==) True
          • Then - Actions
            • Set TempGroup = (Units currently selected by (Triggering player))
            • Unit Group - Pick every unit in ProjectileGroup and do (Actions)
              • Loop - Actions
                • Set TempLoc = ((Position of (Picked unit)) offset by (-200.00, 200.00))
                • Unit - Order (Picked unit) to Move To TempLoc
                • Custom script: call RemoveLocation(udg_TempLoc)
                • Custom script: call DestroyGroup(udg_TempGroup)
          • Else - Actions
        • Multiple FunctionsIf (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • down[(Player number of (Triggering player))] Equal to (==) True
          • Then - Actions
            • Set TempGroup = (Units currently selected by (Triggering player))
            • Unit Group - Pick every unit in ProjectileGroup and do (Actions)
              • Loop - Actions
                • Set TempLoc = ((Position of (Picked unit)) offset by (-200.00, -200.00))
                • Unit - Order (Picked unit) to Move To TempLoc
                • Custom script: call RemoveLocation(udg_TempLoc)
                • Custom script: call DestroyGroup(udg_TempGroup)
          • Else - Actions

An easy way to add events
  • LeftPressSet
    • Events
      • Time - Elapsed game time is 0.50 seconds
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Trigger - Add to LeftPress <gen> the event (Player - (Player((Integer A))) Presses the Left Arrow key)

  • LeftReleaseSet
    • Events
      • Time - Elapsed game time is 0.50 seconds
    • Conditions
    • Actions
      • Do Multiple ActionsFor each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Trigger - Add to LeftRelease <gen> the event (Player - (Player((Integer A))) Releases the Left Arrow key)
To set left = false when you release
  • LeftRelease
    • Events
    • Conditions
    • Actions
      • Set left[(Player number of (Triggering player))] = False

You will need to make all of this for up, down, and right as well
 
Status
Not open for further replies.
Top