GRADUAL ANIMATION

You must understand the Game Editor concepts, before post here.

GRADUAL ANIMATION

Postby sonicforvergame » Tue Nov 20, 2012 2:45 pm

HI everybody
is there any way so that I can start with a walking animation to go to a running animation than go to a verry fast animation and taking in account the speed of the player ???

if you want something more easy how can i make a sonic animation
slow-->fast-->verry fast
without missing the speed ???
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: GRADUAL ANIMATION

Postby Soullem » Tue Nov 20, 2012 7:03 pm

somebody could probably tell you a more seamless way, but here I go assuming you are doing this for a sonic platformer
First create three variables speed and TimeMove and TimeAnim
on key down right
Code: Select all
TimeMove+=1;
if (TimeAnim<0)
{TimeAnim=0}
TimeAnim+=1;


and on left
Code: Select all
TimeMove-=1;
if (TimeAnim>0)
{TimeAnim=0}
TimeAnim-=1;


then in draw actor add something along the lines of

Code: Select all
if (TimeMove == 0)
{
    speed=0;
}
if (TimeMove <= 10 && TimeMove >0)
{
    speed=2;
}
if (TimeMove <= 20 && TimeMove >10)
{
    speed=4;
}
if ( TimeMove >20)
{
    speed=8;
}
if (TimeMove <= 0 && TimeMove >-10)
{
    speed=-2;
}
if (TimeMove <= -10 && TimeMove >-20)
{
    speed=-4;
}
if ( TimeMove >-20)
{
    speed=-8;
}

xvelocity=speed


then do the same for the animation using Time Anim and ChangeAnimation. If you need any help feel free to ask.
also I would wait to use this and see if someone makes something better.
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: GRADUAL ANIMATION

Postby sonicforvergame » Wed Nov 21, 2012 1:20 pm

Well i didn't understand all
for example the script you have put now what is it for THE SPEED ??
if yes what dose it do
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: GRADUAL ANIMATION

Postby Soullem » Wed Nov 21, 2012 8:49 pm

So the variable TimeMove counts for how long you hold down the left and right arrow keys.
the IF statements set a range for the speed value to change.

Then you set the xvelocity(how fast moving left and right) to equal that speed value.

Heres my code with comments

on key down right

Code: Select all
TimeMove+=2; //add to time holding down right key
if (TimeAnim<0) //if you were moving left set TimeAnim to 0, so he turns to the right right away
{TimeAnim=0;} 
TimeAnim+=2;  //add one to time trying to run right


on key down right
Code: Select all
TimeMove-=2;  //add to time holding down left key, so he turns left right away
if (TimeAnim>0)
{TimeAnim=0;}
TimeAnim-=2;


Draw Actor
Code: Select all
if (TimeMove == 0) //if not pressing key and slowed down
{
    speed=0;  //set speed to 0
}
if (TimeMove <= 10 && TimeMove >0)  //if pressing to the right for 1-10 frames
{
    speed=2; //set speed to 2
}
if (TimeMove <= 20 && TimeMove >10)  //if pressing to the right for 11-20 frames
{
    speed=4;  //set speed to 4
}
if ( TimeMove >20)  // if pressing for more than 20 frames
{
    speed=8; //set speed to eight
}
if (TimeMove <= 0 && TimeMove >-10)  // if holding left for 1-10 frames
{
    speed=-2; //set speed to negative 2
}
if (TimeMove <= -10 && TimeMove >-20) //you get the pattern...
{
    speed=-4;
}
if ( TimeMove <-20)
{
    speed=-8;
}
xvelocity=speed;  // set the xvelocity to be the value of our variable speed
//  xvelocity is how fast the player is moving left and right.
if (TimeMove>0) //check if moving right
{TimeMove-=1; //this decreases the value of TimeMove once a frame so Sonic slows down
}
if (TimeMove<0) //check if moving left
{TimeMove+=1; //this increases the value of TimeMove towards 0 once a frame so Sonic slows down
}

ill make a demo soon...
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: GRADUAL ANIMATION

Postby Soullem » Wed Nov 21, 2012 9:05 pm

Here it is. You can copy the parameters and change TimeMove into TimeAnim for the animation. If you dont understand how to just ask :D
Attachments
MoveTut.zip
(8.66 KiB) Downloaded 190 times
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: GRADUAL ANIMATION

Postby sonicforvergame » Thu Nov 22, 2012 2:54 pm

Thanks soullem that was NICE you really help me here
i will make sure to show you my sonic game when i finish it
thanks again
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: GRADUAL ANIMATION

Postby Soullem » Thu Nov 22, 2012 6:32 pm

No problem, I'm happy to help.

Also you could add more times where it changes speed so its smoother, this is more of a template, im pretty sure if you play around with values you could get it smoother
Current Project:
The Project That needs to be Done -- Pokemon http://game-editor.com/forum/viewtopic.php?f=4&t=12591

Temporarily Abandoned:
Souls of Gustara -- Awesome upgrade blimp game 42%ish
Eggventures of Eggman -- Adventure Game 20%ish
User avatar
Soullem
 
Posts: 105
Joined: Thu Aug 02, 2012 3:12 pm
Score: 5 Give a positive score

Re: GRADUAL ANIMATION

Postby Bee-Ant » Sun Jan 13, 2013 1:12 pm

Maybe I'm late here, but it's OK.
Let me share my method.
Probably this one for other people who come to check this thread :)

PREPARATION

Give the player 3 animations, same animation but with different fps. For example:
- PlayerRunLeft1 ~ 10 fps
- PlayerRunLeft2 ~ 20 fps
- PlayerRunLeft3 ~ 30 fps
- PlayerRunRight1 ~ 10 fps
- PlayerRunRight2 ~ 20 fps
- PlayerRunRight3 ~ 30 fps

Make 3 integer variables via script editor:
- speed
- run
- direct


CODE

Player > KeyDown > Left > ScriptEditor:
Code: Select all
run〓1;
speed++;
x-〓speed/5;
direct〓0;


Player > KeyDown > Right > ScriptEditor:
Code: Select all
run〓1;
speed++;
x+〓speed/5;
direct〓1;


Player > KeyUp > Any Key > ScriptEditor:
Code: Select all
run〓0;


Player > DrawActor > ScriptEditor:
Code: Select all
char str[32];
char directText[3][8]〓{"Left","Right"};
speed〓max(0,min(speed,59)); //limit the speed value
if(run〓〓0)
{
    speed-〓5;
}
sprintf(str,"PlayerRun%s%i",directText[direct],speed/20+1); //get the animation name
ChangeAnimation("Event Actor", str, NO_CHANGE); //change the player animation

if(speed<〓0&&direct〓〓0)ChangeAnimation("Event Actor", "PlayerStopLeft", NO_CHANGE);

if(speed<〓0&&direct〓〓1)ChangeAnimation("Event Actor", "PlayerStopRight", NO_CHANGE);


That's all :)
Any question?
Last edited by Bee-Ant on Sun Jan 13, 2013 1:41 pm, edited 1 time in total.
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: GRADUAL ANIMATION

Postby sonicforvergame » Sun Jan 13, 2013 1:31 pm

YOU ARE AWSOME at acripting that is all and really good i am sure it's going to work anyway i will tell you if it did work or not
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: GRADUAL ANIMATION

Postby sonicforvergame » Sun Jan 13, 2013 1:54 pm

sorry but it didn't quite work ther are some problems i will give you my demo soon so you can see what is wrong is it Bee-Ant
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: GRADUAL ANIMATION

Postby Bee-Ant » Sun Jan 13, 2013 2:29 pm

Another method with simpler code but a bit more complicated preparation:

PREPARATION

Give the player 3 run animations, same animation but with different fps. For example:
- PlayerRunLeft1 ~ 10 fps
- PlayerRunLeft2 ~ 20 fps
- PlayerRunLeft3 ~ 30 fps
- PlayerRunRight1 ~ 10 fps
- PlayerRunRight2 ~ 20 fps
- PlayerRunRight3 ~ 30 fps
And stop animation:
- PlayerStopLeft1 ~ 10 fps
- PlayerStopRight1 ~ 10fps

Make 4 integer variables via script editor:
- speed
- run
- direct
- stop

CODE

Player > KeyDown > Left > ScriptEditor:
Code: Select all
run〓1;
stop〓0;
speed++;
direct〓-1;


Player > KeyDown > Right > ScriptEditor:
Code: Select all
run〓1;
stop〓0;
speed++;
direct〓1;


Player > KeyUp > Any Key > ScriptEditor:
Code: Select all
run〓0;


Player > DrawActor > ScriptEditor:
Code: Select all
char str[32];
char directText[3][8]〓{"Left","None","Right"};
char stateText[2][8]〓{"Run","Stop"};
speed-〓(run〓〓0)*5; //if you release the button, reduce the speed bit by bit
speed〓max(0,min(speed,59)); //limit the speed value
x+〓speed/5*(stop〓〓0)*direct; //x movement decided by speed, stop and direct
sprintf(str,"Player%s%s%i",stateText[stop],directText[direct+1],speed/20+1); //get the animation name
ChangeAnimation("Event Actor", str, NO_CHANGE); //change the player animation
if(speed<〓0&&run〓〓0)stop〓1;
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: GRADUAL ANIMATION

Postby Bee-Ant » Sun Jan 13, 2013 2:33 pm

sonicforvergame wrote:sorry but it didn't quite work ther are some problems i will give you my demo soon so you can see what is wrong is it Bee-Ant

Did you just copy-paste my code?
So sorry but I'm mobile now, and it seems "〓" character here is not the same as "〓" character in PC. So I suggest you to replace it :o
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: GRADUAL ANIMATION

Postby sonicforvergame » Sun Jan 13, 2013 4:26 pm

i did but i think i made a mistake with the preperation i will try the new code
Kaizoku ni ore wa naru
User avatar
sonicforvergame
 
Posts: 422
Joined: Sat Sep 01, 2012 2:17 pm
Score: 10 Give a positive score

Re: GRADUAL ANIMATION

Postby Bee-Ant » Mon Jan 14, 2013 1:25 am

I did try it, and it worked just perfectly. Except for the sudden turn brake... will think about it later :)
I don't know what's wrong with how did you do it, but here's the demo I make:
Attachments
GradualRunningByBeeAnt.zip
(12.34 KiB) Downloaded 183 times
User avatar
Bee-Ant
 
Posts: 3723
Joined: Wed Apr 11, 2007 12:05 pm
Location: http://www.instagram.com/bee_ant
Score: 210 Give a positive score

Re: GRADUAL ANIMATION

Postby GEuser » Mon Jan 14, 2013 1:32 am

Just checked the download. Seems to work fine for me Bee-ant.
GEuser
 
Posts: 204
Joined: Thu Jan 05, 2012 3:08 pm
Score: 19 Give a positive score

Next

Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron