Tutorial Arrow Key Movement / Camera

O

OneEight7eve

Guest
This has been done before but i didn't really like any of the others ones so i made one myself. The difference in this one (from the ones i have tried ) is that its smoother and reacts faster.

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 except for down.
Example:
Code:
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
Code:
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
Code:
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 basically be doing the same thing as the pressed ones but like this
Code:
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. except don't 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 :
Code:
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 :
Code:
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
                        Animation - Change PlayersHero[(Player number of (Triggering player))]'s animation speed to 50.00% of its original speed
                        Animation - Play PlayersHero[(Player number of (Picked player))]'s walk animation
                        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)
                        Custom script:   call RemoveLocation (udg_TempPoint[GetConvertedPlayerId(GetEnumPlayer())])
                    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
                                Animation - Play PlayersHero[(Player number of (Picked player))]'s walk animation
                                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)
                                Custom script:   call RemoveLocation (udg_TempPoint[GetConvertedPlayerId(GetEnumPlayer())])
                            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
                                        Animation - Play PlayersHero[(Player number of (Picked player))]'s walk animation
                                        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)
                                        Custom script:   call RemoveLocation (udg_TempPoint[GetConvertedPlayerId(GetEnumPlayer())])
                                    Else - Actions
                                        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                                            If - Conditions
                                                Down[(Player number of (Picked player))] Equal to True
                                            Then - Actions
                                                Animation - Play PlayersHero[(Player number of (Picked player))]'s walk animation
                                                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 -75.00 towards ((Facing of PlayersHero[(Player number of (Picked player))]) + 0.00) degrees)
                                                Custom script:   call RemoveLocation (udg_TempPoint[GetConvertedPlayerId(GetEnumPlayer())])
                                            Else - Actions

your still not done. now for the diagonal 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 diagonals.

Code:
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 didn't understand it or i didn't explain well take a look at the triggers your self in the demo map (Camera system is in demo map also). . idk if im good or not at explaining things either soooo
 

Attachments

  • 187 Arrow Key Movement 1.2.w3x
    31.7 KB · Views: 446

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
LEAKS!

Fix the leaks and I'll take that off. If you don't know how to check for leaks, here is a tutorial.

Other than the leaks, it looks....large. GJ :)

After testing...it works quite well, however:
The turning increment of the left and right keys are too large. Make it smaller. Its very difficult to do smaller turns as it currently is. Note that there is a large delay from when someone presses the key to when it moves. I don't know how this would react on BNET but i suspect it will be slow. People will compensate for it of course, but I wouldn't advise putting this system on a maze map.

Are you going to put in commands for the down buttons also? It would be great to have the unit reverse while facing forward. (i.e run backwards.) Here's something that might help to that end.

I believe it would be GREAT in an RPG or something like that. Maybe also a unique twist to a TD?

If anyone could be bothered to, this would be excellent turned into jass or structs and optimized.
 

Sim

Forum Administrator
Staff member
Reaction score
534
What does this arrow key movement system offers that is different from the others?

We already have a ton and you know it.
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
Have you tried it? It is different to the others. (well the ones I've tried anyway.)
 

Sim

Forum Administrator
Staff member
Reaction score
534
> im pretty sure i spelled alot of things wrong so dont tell me about it.

No, I tell you: It is not accepted. Fix the spelling and grammar mistakes.

> im pretty sure i spelled alot of things wrong so dont tell me about it.

He has to state in which way in his tutorial, otherwise anybody reading this will think it is just the same as the others.
 

chovynz

We are all noobs! in different states of Noobism!
Reaction score
130
Okiedokie :D

> im pretty sure i spelled alot of things wrong so dont tell me about it.

That isn't acceptable in a tutorial. Like Dax said, you will need to be explicit in your spelling and grammer as well as the leak checking.
 
O

OneEight7eve

Guest
ok i fixed most spelling and added version 1.1

VERSION UPDATES: 1.1
.Units react faster when pushing "up" Key
.made more smooth (you can change this to w/e u want to get different looks)
.made multi-player
.Fixed leaks (i think)
 

Sim

Forum Administrator
Staff member
Reaction score
534
> system. in case you didn't understand it or i didn't explain well take a look at the triggers your self in the demo map (Camera system is in demo map also). . idk if im good or not at explaining things either soooo

Sentences start with a capitalized letter. "I", not "i". Yourself, not your self. Don't end sentences with 2 dots. I don't know, not idk.

These are just examples of the numerous errors throughout the tutorial.

> Every 0.30 seconds of game-time

It might not be smooth enough. Did you try with a lower number? Such as every 0.05 seconds or something?

Do you ever remove TempPoint?
 
O

OneEight7eve

Guest
yes i remove temppoint with custom script (fixed that) , if u did every 0.05 seconds of game time the hero would "twitch" not finishing his walk animation so it would look wierd. i will fix spelling later i gtg soon.
 

Sim

Forum Administrator
Staff member
Reaction score
534
As long as it looks smooth in-game it's ok ;)

Mind posting the whole (or new) code then? Because the TempPoints don't get removed at the moment.
 
O

OneEight7eve

Guest
Version 1.2 is out , the only thing i changed is i made it alot smoother.
 

Argentine

New Member
Reaction score
2
tested and retested....

I have tested this arrow key movement following the tutorial exactly and then I tried changing around animation speeds and the trigger check intervals(a.k.a. time elapsed) and to be honest this is one of the slowest responding arrow key movement triggers I have ever seen.

If you fancy a good arrow key movement system blizzard has one in their "death sheep" map that only moves left and right, you can use that system and pretty much figure out how to copy a trigger and change the variables for moving forward.

In my opinion this tutorial should be either removed or fixed (i doubt after 3 years sitting in the graveyard it will be fixed, but a direct link to this tutorial still comes up on google searches as fairly relevant to "wc3 arrow key movement") :thdown:
 

HydraRancher

Truth begins in lies
Reaction score
197
By the way, it may help to place the code in [noparse]
Trigger:
[/noparse] tags.

Also, I'd be unhappy to play Player 4, because he's missing a "Player presses the right arrow key" event in your example.
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top