1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still haven't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. Rubbed the right way, the genie is out of its lamp! The 12th Concept Art Contest Results have been announced.
    Dismiss Notice
  4. The Lich King has a new champion. The results for the 19th Icon Contest are here!
    Dismiss Notice
  5. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  6. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Arrow Key Movement / Camera System

Discussion in 'Trigger (GUI) Editor Tutorials' started by OneEight7even, Nov 15, 2007.

  1. OneEight7even

    OneEight7even

    Joined:
    Oct 27, 2007
    Messages:
    23
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    this has been done before but i didnt really like any of the others ons so i made one myself.

    Arrow Key Movement

    1.0
    1) Create 3 Variables , named "Up", "Right" , "Left". Make those 3 boolean arrays for the type and make a new variable called Players_Hero with type Unit Array. and another variable named TempPoint and its type point array.

    2) Create a map init trigger and set some unit into the Players_Hero variable

    3) Create a new trigger named "Up Pressed"

    4) add this event to the trigger : Player - Player 1 (Red) Presses the Up Arrow key

    5) add the variable up in the actions part and make it look like this
    Set Up[(Player number of (Triggering player))] = True

    6) Make that for all the arrow keys exept for down.
    Example:
    SPOILER

    • ]Up Press
      • Events
        • Player - Player 1 (Red) Presses the Up Arrow key
        • Player - Player 2 (Blue) Presses the Up Arrow key
        • Player - Player 3 (Teal) Presses the Up Arrow key
        • Player - Player 4 (Purple) Presses the Up Arrow key
      • Conditions
      • Actions
        • Set Up[(Player number of (Triggering player))] = True

    • Right Press
      • Events
        • Player - Player 1 (Red) Presses the Right Arrow key
        • Player - Player 2 (Blue) Presses the Right Arrow key
        • Player - Player 3 (Teal) Presses the Right Arrow key
      • Conditions
      • Actions
        • Set Right[(Player number of (Triggering player))] = True

    • Left Press
      • Events
        • Player - Player 1 (Red) Presses the Left Arrow key
        • Player - Player 2 (Blue) Presses the Left Arrow key
        • Player - Player 3 (Teal) Presses the Left Arrow key
        • Player - Player 4 (Purple) Presses the Left Arrow key
      • Conditions
      • Actions
        • Set Left[(Player number of (Triggering player))] = True


    1.1
    Now we are going to create the "release triggers" you will basicly be doing the same thing as the pressed ones but like this
    • Up Release
      • Events
        • Player - Player 1 (Red) Releases the Up Arrow key
        • Player - Player 2 (Blue) Releases the Up Arrow key
        • Player - Player 3 (Teal) Releases the Up Arrow key
        • Player - Player 4 (Purple) Releases the Up Arrow key
      • Conditions
      • Actions
        • Set Up[(Player number of (Triggering player))] = False
        • Unit - Order PlayersHero[(Player number of (Triggering player))] to Stop


    Now do that for all the arrow keys. exept dont add the Unit - Order Stop action in any of the other ones.

    2.0
    Create a new trigger named Movement. this trigger will be detecting the variables to order a unit to move. for example :
    if the variable Up is = True then it will move that unit up.
    1) create the event Time - Every 0.25 seconds of game time

    2) add the action Player Group - Pick all players and do actions
    Loop actions

    3) in the loop actions part create an If/Then/Else action. so far it should look like this :
    • Untitled Trigger 001
      • Events
        • Time - Every 0.25 seconds of game time
      • Conditions
      • Actions
        • Player Group - Pick every player in (All players) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
              • Then - Actions
              • Else - Actions


    in the If - Conditions part of the trigger add these conditions
    • Up[(Player number of (Picked player))] Equal to True
    • Left[(Player number of (Picked player))] Equal to False
    • Right[(Player number of (Picked player))] Equal to False
    .

    4) after that , create under the Then -Actions part the variable TempPoint like this
    • Set TempPoint[(Player number of (Picked player))] = (Position of PlayersHero[(Player number of (Picked player))])
    after that action were going to add the moving part of it it should look like this
    • Unit - Order PlayersHero[(Player number of (Picked player))] to Move To (TempPoint[(Player number of (Picked player))] offset by 90.00 towards (Facing of PlayersHero[(Player number of (Picked player))]) degrees)


    Now do the same thing in more loops for all the variables. it should look like this at the end :
    SPOILER
    • Movement
      • Events
        • Time - Every 0.25 seconds of game time
      • Conditions
      • Actions
        • Player Group - Pick every player in (All players) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Up[(Player number of (Picked player))] Equal to True
                • Left[(Player number of (Picked player))] Equal to False
                • Right[(Player number of (Picked player))] Equal to False
              • Then - Actions
                • Set TempPoint[(Player number of (Picked player))] = (Position of PlayersHero[(Player number of (Picked player))])
                • Unit - Order PlayersHero[(Player number of (Picked player))] to Move To (TempPoint[(Player number of (Picked player))] offset by 90.00 towards (Facing of PlayersHero[(Player number of (Picked player))]) degrees)
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Right[(Player number of (Picked player))] Equal to True
                  • Then - Actions
                    • Set TempPoint[(Player number of (Picked player))] = (Position of PlayersHero[(Player number of (Picked player))])
                    • Unit - Order PlayersHero[(Player number of (Picked player))] to Move To (TempPoint[(Player number of (Picked player))] offset by 90.00 towards ((Facing of PlayersHero[(Player number of (Picked player))]) + -90.00) degrees)
                  • Else - Actions
                    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                      • If - Conditions
                        • Left[(Player number of (Picked player))] Equal to True
                      • Then - Actions
                        • Set TempPoint[(Player number of (Picked player))] = (Position of PlayersHero[(Player number of (Picked player))])
                        • Unit - Order PlayersHero[(Player number of (Picked player))] to Move To (TempPoint[(Player number of (Picked player))] offset by 90.00 towards ((Facing of PlayersHero[(Player number of (Picked player))]) + 90.00) degrees)
                      • Else - Actions


    You're still not done. now for the diaganol movement part. we wont be actually ordering the unit to move diaganol we will move him instantly to point. this is pretty simple so im just going to post the trigger for diaganols.

    • Stop Turn
      • Events
        • Time - Every 0.30 seconds of game time
      • Conditions
      • Actions
        • Player Group - Pick every player in (All players) and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Up[(Player number of (Picked player))] Equal to True
                • Left[(Player number of (Picked player))] Equal to True
              • Then - Actions
                • Unit - Make PlayersHero[(Player number of (Picked player))] face ((Facing of PlayersHero[(Player number of (Picked player))]) + 65.00) over 0.10 seconds
                • Set TempPoint[(Player number of (Picked player))] = ((Position of PlayersHero[(Player number of (Picked player))]) offset by 10.00 towards (Facing of PlayersHero[(Player number of (Picked player))]) degrees)
                • Unit - Move PlayersHero[(Player number of (Picked player))] instantly to TempPoint[(Player number of (Picked player))]
                • Animation - Play PlayersHero[(Player number of (Picked player))]'s walk animation
              • Else - Actions
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Up[(Player number of (Picked player))] Equal to True
                    • Right[(Player number of (Picked player))] Equal to True
                  • Then - Actions
                    • Unit - Make PlayersHero[(Player number of (Picked player))] face ((Facing of PlayersHero[(Player number of (Picked player))]) + -65.00) over 0.10 seconds
                    • Set TempPoint[(Player number of (Picked player))] = ((Position of PlayersHero[(Player number of (Picked player))]) offset by -10.00 towards (Facing of PlayersHero[(Player number of (Picked player))]) degrees)
                    • Unit - Move PlayersHero[(Player number of (Picked player))] instantly to TempPoint[(Player number of (Picked player))]
                    • Animation - Play PlayersHero[(Player number of (Picked player))]'s walk animation
                  • Else - Actions


    There you go you made an arrow key movement system. in case you didnt understand it or i didnt explain well take a look at the triggers your self in the demo map (Camera system is in demo map also). im pretty sure i spelled alot of things wrong so dont tell me about it. idk if im good or not at explaining things either soooo
     

    Attached Files:

    Last edited by a moderator: Feb 10, 2008
  2. madcat2

    madcat2

    Joined:
    Aug 25, 2005
    Messages:
    1,138
    Resources:
    0
    Resources:
    0
    Good Tutorial but it'd probably be better with some pictures here and there.

    ~/\/\@D
     
  3. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    I suggest replacing the
    Code (Text):
     tags with [trigger] tags, which are specifically built for GUI.

    For the spoilers, you could use [noparse][hidden=Spoiler](content)[/hidden][/noparse], which would produce:

    [hidden=Spoiler](content)[/hidden]

    Also, Unit - Move Unit (Instantly) resets animations as far as I know, so that would look a little jumpy.
     
  4. SoCal_420

    SoCal_420

    Joined:
    Jun 23, 2007
    Messages:
    6
    Resources:
    0
    Resources:
    0
    nice system i could use it.
     
  5. Kieve

    Kieve

    Joined:
    Nov 19, 2007
    Messages:
    8
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Is [that] how button (hold) functions work? Hm. Need the pair of Press and Release event triggers.
    Seems so obvious, and yet it never occurred to me before. Wonderful.
    Not too keen on the rest of the code, but that's personal preference - easy to understand at least.
     
  6. Need_O2

    Need_O2

    Joined:
    Aug 24, 2007
    Messages:
    2,880
    Resources:
    0
    Resources:
    0
    would be better with JASS
    hey dont look at me like that Im a Lamer
    My job is causing annoying situations

    Ups including much leaks too
     
  7. CombatTheWombat

    CombatTheWombat

    Joined:
    Jul 30, 2007
    Messages:
    884
    Resources:
    5
    Models:
    1
    Icons:
    1
    Skins:
    3
    Resources:
    5
    hmmmm, dont use jass for anything you can do in gui, as the saying goes, "don't fix what isn't broken"
     
  8. PurplePoot

    PurplePoot

    Joined:
    Dec 14, 2005
    Messages:
    11,161
    Resources:
    3
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    Resources:
    3
    That's absolutely not true, but on the other hand, some people use GUI too, so GUI tuts are useful too...
     
  9. Wolverabid

    Wolverabid

    Joined:
    Oct 23, 2006
    Messages:
    8,302
    Resources:
    5
    Tutorials:
    5
    Resources:
    5
    Tutorial Approved!

    Map makers should find this tutorial helpful and useful.

    ~ Thread moved to Trigger (GUI) Editor Tutorials.
     
  10. Deathcom3s

    Deathcom3s

    Joined:
    Dec 24, 2007
    Messages:
    1,282
    Resources:
    1
    Models:
    1
    Resources:
    1
    Nice tut, I'm going to use this in my RPG.
     
  11. ~Void~

    ~Void~

    Joined:
    Jul 1, 2007
    Messages:
    6,448
    Resources:
    14
    Icons:
    8
    Skins:
    2
    Tutorials:
    4
    Resources:
    14
    But GUI is leaktastic!
     
  12. underscore

    underscore

    Joined:
    Mar 17, 2008
    Messages:
    150
    Resources:
    0
    Resources:
    0
    Thank you for the tutorial. It helped me make my Role-playing a little nice. 5/5
     
  13. Kidd|WhiteHeaven|

    Kidd|WhiteHeaven|

    Joined:
    Nov 4, 2006
    Messages:
    266
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Great and usefull. Especially for dodgeball type games.
    Note: FPS view cameras really are hard.
     
  14. Pandarian-Warrior

    Pandarian-Warrior

    Joined:
    Apr 4, 2008
    Messages:
    4
    Resources:
    0
    Resources:
    0
    dude...i just learned how to make an arrow-key movement system.
    thank you, thank you very much
     
  15. Bill_14

    Bill_14

    Joined:
    Jan 11, 2008
    Messages:
    6
    Resources:
    0
    Resources:
    0
    my opinion is do not try to make such a system

    i made one for my rpg map, and the unit is walking awfully, it is like right clicking 4 times a seconds in front of the unit. Also if there is an obstacle in front of the unit, it won't go str8.

    it's good however to show to people how to do this, even for practice, good work
     
  16. OneEight7even

    OneEight7even

    Joined:
    Oct 27, 2007
    Messages:
    23
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    Lol thanks for all the comments
     
  17. Oziris

    Oziris

    Joined:
    Oct 14, 2006
    Messages:
    4,109
    Resources:
    3
    Icons:
    1
    StarCraft II Resources:
    1
    Tutorials:
    1
    Resources:
    3
    Can u make W up S down D right and A left ? becous ther is a new tutorial called zoom in and rotating with arrow keys and in most rpgs Movement is on W A S D !
     
    Last edited: May 10, 2008
  18. OneEight7even

    OneEight7even

    Joined:
    Oct 27, 2007
    Messages:
    23
    Resources:
    1
    Tutorials:
    1
    Resources:
    1
    no

    A is for attack
    s is for stop
     
  19. Re8eL

    Re8eL

    Joined:
    Dec 11, 2004
    Messages:
    94
    Resources:
    2
    Maps:
    2
    Resources:
    2
    Its a nice way to make a movement system

    Its a nice way to make a movement system, but I think iv created one much better for my new Heavy Combat 3 map in production, its similar to Heavy Combat 2's Movement system but a lot smoother and you can strafe.

    I may release it in the spell area and as a tutorial after HC3 is complete.

    UPDATE:

    Oh, and WASD Movement is impossible. (or atleast GOOD WASD movement.)
     
  20. Discohydra

    Discohydra

    Joined:
    Dec 16, 2007
    Messages:
    161
    Resources:
    0
    Resources:
    0
    Does this make the unit move like a tank? Like.....

    Up + Right = Turn right and move forward
    Up + left = Turn left and move forward
    Down + left = turn right while going backwards
    Down + right = turn left while going backwards

    If it is this is the exact thing i was looking for.
    If not, Ill try making my own.