Ok i finaly solved this problem, it's not that complex it just requres a lot of typing or in your case copying and pasting
. Note that this will make your character go only up, down, left and right, but that can easily be changed to more animations just follow the patern in wich this was done.
For all others who had this problem, for this to work properly your animations have to be called: run_right, run_up... stop_left, stop_down or change the code but i think the first option is faster.
Now il explain how this code works.
Draw Actor-Script Editor
- Code: Select all
char *key=GetKeyState();
if
(key[KEY_UP]==1&&key[KEY_DOWN]==0&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==0) y-=2;
else if (key[KEY_UP]==0&&key[KEY_DOWN]==1&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==0) y+=2;
else if (key[KEY_UP]==0&&key[KEY_DOWN]==0&&key[KEY_LEFT]==1&&key[KEY_RIGHT]==0) x-=2;
else if (key[KEY_UP]==0&&key[KEY_DOWN]==0&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==1) x+=2;
This checks wich keys are pressed at all times and moves or stops the actor acorrdingly.
Key Down(Left)-Script Editor(Repeat:Disable, At least one key is pressed)- Code: Select all
char *key=GetKeyState();
if (key[KEY_UP]==0&&key[KEY_RIGHT]==0&&key[KEY_DOWN]==0)
ChangeAnimation("Event Actor", "run_left", FORWARD);
else if (key[KEY_UP]==1&&key[KEY_RIGHT]==0&&key[KEY_DOWN]==0)
ChangeAnimation("Event Actor", "stop_up", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_RIGHT]==1&&key[KEY_DOWN]==0)
ChangeAnimation("Event Actor", "stop_right", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_RIGHT]==0&&key[KEY_DOWN]==1)
ChangeAnimation("Event Actor", "stop_down", FORWARD);
This code checks wich keys are already pressed when you press a new key, then it stops the actor facing the way he was facing before the key was pressed. This code is simillar for all key down events but requires modifiying so il just post it and make it easier for all of you.
Key Down(Right)-Script Editor(Repeat:Disable, At least one key is pressed)- Code: Select all
char *key=GetKeyState();
if (key[KEY_UP]==0&&key[KEY_LEFT]==0&&key[KEY_DOWN]==0)
ChangeAnimation("Event Actor", "run_right", FORWARD);
else if (key[KEY_UP]==1&&key[KEY_LEFT]==0&&key[KEY_DOWN]==0)
ChangeAnimation("Event Actor", "stop_up", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_LEFT]==1&&key[KEY_DOWN]==0)
ChangeAnimation("Event Actor", "stop_left", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_LEFT]==0&&key[KEY_DOWN]==1)
ChangeAnimation("Event Actor", "stop_down", FORWARD);
Key Down(Down)-Script Editor(Repeat:Disable, At least one key is pressed)- Code: Select all
char *key=GetKeyState();
if (key[KEY_UP]==0&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "run_down", FORWARD);
else if (key[KEY_UP]==1&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "stop_up", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_LEFT]==1&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "stop_left", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==1)
ChangeAnimation("Event Actor", "stop_right", FORWARD);
Key Down(Up)-Script Editor(Repeat:Disable, At least one key is pressed)- Code: Select all
char *key=GetKeyState();
if (key[KEY_DOWN]==0&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "run_up", FORWARD);
else if (key[KEY_DOWN]==1&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "stop_down", FORWARD);
else if (key[KEY_DOWN]==0&&key[KEY_LEFT]==1&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "stop_left", FORWARD);
else if (key[KEY_DOWN]==0&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==1)
ChangeAnimation("Event Actor", "stop_right", FORWARD);
Now we come to the key up events wich check wich keys are pressed when you release a key and changes the animation accordingly.
Key Up(Left)-Script Editor- Code: Select all
char *key=GetKeyState();
if (key[KEY_UP]==0&&key[KEY_DOWN]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "stop_left", FORWARD);
else if (key[KEY_UP]==1&&key[KEY_DOWN]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "run_up", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_DOWN]==1&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "run_down", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_DOWN]==0&&key[KEY_RIGHT]==1)
ChangeAnimation("Event Actor", "run_right", FORWARD);
Key Up(Right)-Script Editor- Code: Select all
char *key=GetKeyState();
if (key[KEY_UP]==0&&key[KEY_DOWN]==0&&key[KEY_LEFT]==0)
ChangeAnimation("Event Actor", "stop_right", FORWARD);
else if (key[KEY_UP]==1&&key[KEY_DOWN]==0&&key[KEY_LEFT]==0)
ChangeAnimation("Event Actor", "run_up", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_DOWN]==1&&key[KEY_LEFT]==0)
ChangeAnimation("Event Actor", "run_down", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_DOWN]==0&&key[KEY_LEFT]==1)
ChangeAnimation("Event Actor", "run_left", FORWARD);
Key Up(Down)-Script Editor- Code: Select all
char *key=GetKeyState();
if (key[KEY_UP]==0&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "stop_down", FORWARD);
else if (key[KEY_UP]==1&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "run_up", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_LEFT]==1&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "run_left", FORWARD);
else if (key[KEY_UP]==0&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==1)
ChangeAnimation("Event Actor", "run_right", FORWARD);
Key Up(Up)-Script Editor- Code: Select all
char *key=GetKeyState();
if (key[KEY_DOWN]==0&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "stop_up", FORWARD);
else if (key[KEY_DOWN]==1&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "run_down", FORWARD);
else if (key[KEY_DOWN]==0&&key[KEY_LEFT]==1&&key[KEY_RIGHT]==0)
ChangeAnimation("Event Actor", "run_left", FORWARD);
else if (key[KEY_DOWN]==0&&key[KEY_LEFT]==0&&key[KEY_RIGHT]==1)
ChangeAnimation("Event Actor", "run_right", FORWARD);
And thats it just copy and paste it and you should have no problem. I'm sure that there are much faster and better ways to do this and if you know one please share it with us.
Hope this helps everyone who had this problem (almost everybody, including me) and i hope that there will be a way to do this faster in next versions of GE.
Alex_XelA wrote:The user-forum is highly active, friendly and useful when you need help.
Quoted from the Game Editor reminder message.
I really thought you guys would help me, I'm sure it's just a small glitch, please! My trial version is for only one month, and I haven't even completed a decent walking engine.
We are helpful, just give us some time
my internet connection was dead a few days so i couldn't help.