Hi,I messed around pretty much with the editor,but I can't seem to get this right:I want a arrow-keys-movement-system for 8-10 players,with as less lag as possible.
Any help would be appreciated :)
(I didn't put any time into making a mouse-aiming sytem yet,but I don't think it will be that hard).
Heres the rough pseudocode for what you're trying to do.
Use an two array's with 8-10 spaces to store the arrow states.
int[8] vert;
int[8] horz;
Initialize them to 0 to represent no button presses.
Event: Any player presses arrow key:
For the Triggering Player.
If Up pressed, vert + 1
If Down Pressed, vert - 1
If Left Pressed, horz - 1
If Right Pressed, horz + 1
Do the opposite if the buttons are released.
If both vert and horz for the player are not zero.
Enable the movement trigger for the player, using either move instantly or order unit to move to location.
Use the vert and horz integer states to calculate the direction you should be moving.
Example: vert = 1, horz = 1, Indicates the unit should move upwards towards the right.
Try to find a trigonometric formula that maps all these states to make it easier. I'm too tired to think of it right now, so good luck. :P
else Disable the movement trigger to save processing power.
The movement trigger should run with a periodic event. With an interval of maybe 0.05, depending on how smooth you want the movement to be.
Sorry bout the bullet point spam. The posting system is gonna ignore all my nextline chars if i don't use them.
Edit: Warning though.. You're gona have to wait til pattch 1.2 comes out before Blizzard fixes the key lag issue. Also, if you're trying to program movement that traces the mouse.. Wait til 1.2, Its pretty hard to do mouse tracking as it is now.
I think I made something that should work:When you press -for example- up,the variable called vertical 1 (,1 for player 1) gets set to 1.The move trigger makes the unit move targeting the relative point which is set by the variables every 0.5 seconds.So if variable "vertical" is set to 1,the relative point will be set 1 (distance) away from the unit towards the upper-side of the map.And because the trigger makes this happen every 0.5 seconds,the unit will never reach that point,so it wil continue walking.The only way to make it stop is by releasing the button.
But nothing happens when I press a button!
Could someone tell me what i'm doing wrong?
(This somehow sounds more like a tutorial then a question).
I'm currently doing some experimentation with the arrow keys as well. For some annoying reason, it doesn't register all the key actions. If too many keys are hit, it only catches say 3 of 4 of the keystrokes, and ignores one of them. This can lead to the key press flags getting stuck and screwing up the code.
Anyway, could you perhaps post a screenshot of your code? Would be easier for someone to step up and help that way. I'll get back to you tommorrow.. Its 2am here so i really gota get to bed.. =/
If you're looking for alternatives, you might want to take a look at progammers data only WASD move system tutorial/library?
Ah, I see why its not working.
When up key pressed, It appears this is what was done.
Quote:
Vertical = 1;
Change it to
Quote:
Vertical = Vertical + 1;
When down is pressed,
Quote:
Vertical = Vertical - 1;
This way, if up and down are both pressed, vertical will equate to 0, thus indicating no movement on the Y-axis.
When the up key is released, you will also need to make sure you do:
Quote:
Vertical = Vertical - 1;
So that vertical will equate to -1, indicating the down key is still pressed.
Fix this for the horizontal (x-axis) as well and it should work.
The default value for both Vertical and Horizontal are 0. So if Vertical + Horizonal = 0, Disable the move trigger so you don't burn up unnecessary processor power, causing latency.
Hi,I messed around pretty much with the editor,but I can't seem to get this right:I want a arrow-keys-movement-system for 8-10 players,with as less lag as possible.
Any help would be appreciated :)
(I didn't put any time into making a mouse-aiming sytem yet,but I don't think it will be that hard).
@Ivono: Go
Heres the rough pseudocode for what you're trying to do.
Use an two array's with 8-10 spaces to store the arrow states.
int[8] vert; int[8] horz;
Initialize them to 0 to represent no button presses.
If both vert and horz for the player are not zero.
The movement trigger should run with a periodic event. With an interval of maybe 0.05, depending on how smooth you want the movement to be.
Sorry bout the bullet point spam. The posting system is gonna ignore all my nextline chars if i don't use them.
Edit: Warning though.. You're gona have to wait til pattch 1.2 comes out before Blizzard fixes the key lag issue. Also, if you're trying to program movement that traces the mouse.. Wait til 1.2, Its pretty hard to do mouse tracking as it is now.
@FuzzYD: Go
K,I'll try this out right now.And my game is not even near to done,but thx for the advice anyway ^_^ I really appreciate it.
I think I made something that should work:When you press -for example- up,the variable called vertical 1 (,1 for player 1) gets set to 1.The move trigger makes the unit move targeting the relative point which is set by the variables every 0.5 seconds.So if variable "vertical" is set to 1,the relative point will be set 1 (distance) away from the unit towards the upper-side of the map.And because the trigger makes this happen every 0.5 seconds,the unit will never reach that point,so it wil continue walking.The only way to make it stop is by releasing the button.
But nothing happens when I press a button!
Could someone tell me what i'm doing wrong?
(This somehow sounds more like a tutorial then a question).
@Ivono: Go
I'm currently doing some experimentation with the arrow keys as well. For some annoying reason, it doesn't register all the key actions. If too many keys are hit, it only catches say 3 of 4 of the keystrokes, and ignores one of them. This can lead to the key press flags getting stuck and screwing up the code.
Anyway, could you perhaps post a screenshot of your code? Would be easier for someone to step up and help that way. I'll get back to you tommorrow.. Its 2am here so i really gota get to bed.. =/
If you're looking for alternatives, you might want to take a look at progammers data only WASD move system tutorial/library?
Alright,I put some screenshots as attachments
Also,I found something that might be interesting... http:forums.sc2mapster.com/resources/tutorials/10104-tutorial-lagless-wasd-system-using-data-editor/
@Ivono: Go
Ah, I see why its not working. When up key pressed, It appears this is what was done.
Change it to
When down is pressed,
This way, if up and down are both pressed, vertical will equate to 0, thus indicating no movement on the Y-axis.
When the up key is released, you will also need to make sure you do:
So that vertical will equate to -1, indicating the down key is still pressed.
Fix this for the horizontal (x-axis) as well and it should work. The default value for both Vertical and Horizontal are 0. So if Vertical + Horizonal = 0, Disable the move trigger so you don't burn up unnecessary processor power, causing latency.