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 havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    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.

Key Movement

Discussion in 'StarCraft II Modding' started by Lee_Go, Aug 3, 2010.

  1. Lee_Go

    Lee_Go

    Joined:
    May 1, 2009
    Messages:
    156
    Resources:
    0
    Resources:
    0
    Hi

    Could someone show me how to do movement with a single marine with using the arrow keys except not first person movement.
    It's a set camera and so I need down to make him go down, up go up, left go left, right go right.



    \ | /
    -- -- <--- Movement
    / | \

    And if anyone knows how to do left and right make him go NorthWest angled movement.
     
  2. splashy5

    splashy5

    Joined:
    Jul 22, 2007
    Messages:
    259
    Resources:
    0
    Resources:
    0
    pretty simple you make a trigger for each key for when it goes down it sets a Boolean to true and when you lift it up it sets it to false, then you have a trigger that runs every half second with an if statement ordering the unit to go up if W is pushed or north east if W and D are down
     
  3. Just_Spectating

    Just_Spectating

    Joined:
    May 16, 2007
    Messages:
    7,023
    Resources:
    46
    Models:
    11
    Icons:
    9
    Skins:
    26
    Resources:
    46
    you'll want to move the unit by triggers and make it play it's walk animation instead so that you can also attack while moving
     
  4. Rispetto

    Rispetto

    Joined:
    Jul 1, 2009
    Messages:
    1,080
    Resources:
    3
    Tutorials:
    3
    Resources:
    3
    I agree with Just Spectating.
    Have a trigger run it's walk animation when the player hits a key,
    Then use the trigger to push the unit in xxx direction, while altering it's facing angle.
     
  5. gosho

    gosho

    Joined:
    Jun 17, 2008
    Messages:
    46
    Resources:
    0
    Resources:
    0
  6. Dr Super Good

    Dr Super Good

    Spell Reviewer

    Joined:
    Jan 18, 2005
    Messages:
    25,806
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    You have a perodic trigger which moves him to his current location + x offset and y offset. This trigger should use game time
    When left is pressed, remove 1 from x offset and add 1 when released.
    When right is pressed, add 1 to x offset and remove 1 when released.
    When down is pressed, remove 1 from y offset and add 1 when released.
    When up is pressed, add 1 to y offset and remove 1 when released.

    If both offsets enter the 0 state when a movement direction is pressed or released, turn off the perodic movememnt trigger.
    If both offsets were in the 0 state but enter the non 0 state then turn on the perodic movement trigger.

    That simple
     
  7. Lee_Go

    Lee_Go

    Joined:
    May 1, 2009
    Messages:
    156
    Resources:
    0
    Resources:
    0
    Urg, that was stupid of me to ask, I already knew to do the movement thing, it was turning I was curious about, but I'll ask about that when I need it. I actually got a lot out this anyway, moving unit while playing animation makes much more sense.

    One more thing, not answered was the diagonal movement, can you have it so if you're already holding down the left key and then you press the up key while still holding left to flow from moving left to move diagonally top left? Or must the left key be re-pressed or something? Just anything on diagonal movement. Rep+ to all after last diagonal question.
     
  8. Rispetto

    Rispetto

    Joined:
    Jul 1, 2009
    Messages:
    1,080
    Resources:
    3
    Tutorials:
    3
    Resources:
    3
    /logic
     
  9. Just_Spectating

    Just_Spectating

    Joined:
    May 16, 2007
    Messages:
    7,023
    Resources:
    46
    Models:
    11
    Icons:
    9
    Skins:
    26
    Resources:
    46
    with the triggers explained above,
    the unit will constantly move in the pressed direction until the button is released.

    therefore, if two buttons are pressed at the same time, the unit will move in both directions at the same time, which, if those buttons are in non opposing directions, will make a diagonal.
     
  10. Lee_Go

    Lee_Go

    Joined:
    May 1, 2009
    Messages:
    156
    Resources:
    0
    Resources:
    0
    Thanks everyone,

    +rep to all
     
  11. erealmz

    erealmz

    Joined:
    Aug 4, 2010
    Messages:
    4
    Resources:
    0
    Resources:
    0
    Wow that is so much better than the mess I created. What I did was this.

    I created two regions called left/right and up/down.
    left/right had a width of the entire map and a height of 1 grid square.
    up/down had a height of the entire map and a width of 1 grid square.

    Then I made 4 regions called north, east, south and west.

    I made a trigger so that every 1 game second, this:

    Region - Move left/right to (Center of (Selected units for player 1))
    Region - Move up/dwn to (Center of (Selected units for player 1))
    Region - Move North to (Top-right of up/dwn bounds)
    Region - Move East to (Top-right of left/right bounds)
    Region - Move South to (Bottom-left of up/dwn bounds)
    Region - Move West to (Bottom-left of left/right bounds)

    Then made the movement triggers as follows:

    Move North:

    UI - Player Any Player presses Up key Down with shift Exclude, control Exclude, alt Exclude
    Trigger - Turn north (S) On
    Trigger - Turn east (S) Off
    Trigger - Turn south (S) Off
    Trigger - Turn west (S) Off
    Unit - Order (Unit 1 from (Selected units for player 1)) to ( Move targeting (Center of North)) (Replace Existing Orders)

    That is to move him.... to stop him is this:

    north (S)

    UI - Player Any Player presses Up key Up with shift Exclude, control Exclude, alt Exclude
    Unit - Order (Unit 1 from (Selected units for player 1)) to ( Stop) (Replace Existing Orders)

    I did the same for east, south and west.

    It all works fine with no bugs but damn thats a lot of work for something that you have explained to be a lot easier to accomplish.

    Thanks.
     
  12. erealmz

    erealmz

    Joined:
    Aug 4, 2010
    Messages:
    4
    Resources:
    0
    Resources:
    0
    Here's my revised version...

    ====== START NORTH ======
    Event:
    UI - Player Any Player presses Up key Down with shift Exclude, control Exclude, alt Exclude

    Condition:
    startNorth == 1

    Action:
    Variable - Set alwaysNorth = 1

    Animation - Play Walk Attack animation for (Actor for (Unit 1 from (Selected units for player 1))) as Default, using Play Forever, Model Driven Looping options and Default Time blend time

    Unit - Make (Unit 1 from (Selected units for player 1)) face 90.0 over 0.3 seconds

    ===== ALWAYS MOVE NORTH =====

    Event:
    Timer - Every 0.0001 seconds of Game Time

    Condition:
    alwaysNorth == 1

    Action:
    Data Table - Save (Position of (Unit 1 from (Selected units for player 1))) as "point" in the Global data table

    Unit - Move (Unit 1 from (Selected units for player 1)) instantly to (("point" from the Global data table) offset by (0.0, 0.3)) (Blend)


    ===== STOP GOING NORTH =====

    Event:
    UI - Player Any Player presses Up key Up with shift Exclude, control Exclude, alt Exclude

    Condition:
    stopNorth == 1

    Action:
    Variable - Set alwaysNorth = 0
    Animation - Play Stand animation for (Actor for (Unit 1 from (Selected units for player 1))) as Default, using Play Forever options and Default Time blend time

    =======================

    Just do the same for East, South and West.... and make the units turn respectively for each. This is still very buggy but its a start. Thanks to this thread I got the idea to do this right and it works pretty good so far.