Issue scripting jump animation

Posted By: emo10001

Issue scripting jump animation - 06/09/11 14:52

Hey Everyone

I've modified the Improved Player Movement from the wiki with a 3rd person camera. Because of that, I need my player to have animations when walking/running/jumping.

Running the animation for walking/running is no problem, but I'm really struggling to get the animation to play correctly when jumping.

Right now, if you press key_space, it begins the animation, but then stops. The jump continues, but with the walking animation (or standing animation, whichever is appropriate).

I'm using STATES for the animation. I've been reading a lot of tutorials, and the manual. I think it might be because of the ANM_CYCLE mode, as the manual says it's for "Cyclic animation scene, like walking or running. Otherwise it's a noncyclic scene like jumping or shooting."

So is there another mode that would play the entire jump animation cycle? If I just remove ANM_CYCLE, I get an error. Is there a noncyclic mode?

Here's my jump STATE code:

Code:
if(key_space == 1)
		{my.STATE = 3;}
		if (my.STATE ==3)
		{
			var height = (key_space)*15*time_step;
			my.ANIMATION += 1*height;
			ent_animate(me,"jump",my.ANIMATION,ANM_CYCLE);
		
			if(grounddist-minv(movedir.z*time_step, grounddist) == 0)
			{
				//jump
				if(key_space)
				{
					movedir.z = -jumpacc;
				}
			}
		}



Any help would be greatly appreciated!

Emo
Posted By: painkiller

Re: Issue scripting jump animation - 06/09/11 16:45

you can use 0 instead of ANM_CYCLE
Posted By: emo10001

Re: Issue scripting jump animation - 06/09/11 18:12

Hehe...yeah I just finally figured that out. However, with it being in the rest of the script...it still just runs 1 frame of the animation, continues the jump with the standing or walking animation.

I've also been moving it around a little. Now, when I load the level...I can walk/strafe/run...etc....but as soon as I hit key_space, it runs through the animation one time...and then I can't make any other movements. The level isn't crashing (as far as I can tell), but my player movement locks up.

Heres my full code:

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <mtlFX.c>

#define STATE     skill1
#define ANIMATION skill2

var jump_percentage;
///////////////////////////////

function main()
{
	//video_screen = 1;
	detail_size = 2;
	level_load("testgame.wmb");

}

function camera_follow(ENTITY* ent)
{
	while(1) 
	{
		vec_set(camera.x,vector(-150,10,50));  // camera position relative to the player      
		vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
		vec_add(camera.x,ent.x);      // add player position
		vec_set(camera.pan,vector(ent.pan,-13,0)); // look in player direction, slighty down      
		wait(1);
	}
}

action aPlayer()
{
	camera_follow(me);
	
	//Parameter
	//var movespeed = 10.0/16.0;
	var movespeed = 15;
	var turnspeed = 13;
	var fallacc = 3.68;
	var jumpacc = 20;
	
	//Temporary
	VECTOR movedir;
	vec_set(movedir, vector(0, 0, 0));
	ANGLE rotdir;
	vec_set(rotdir, vector(0, 0, 0));
	var grounddist;
	
	//determine player height
	c_setminmax(my);
	wait(1);
	var feedheight = -my.min_z;
	
	//adjust bounding box
	my.min_x *= 0.7;
	my.min_y *= 0.8;
	my.min_z = 0;
	my.max_x *= 0.7;
	my.max_y *= 0.8;
	my.max_z *= 0.8;
	
	//start camera funtions
	//updateCam(my);
	
	proc_mode = PROC_EARLY;
	while(1)
	{
		if (!key_cuu & !key_cud)
		{my.STATE = 2;}
		
		if (key_cuu ==1 | key_cud ==1 | key_ctrl ==1 | key_ins ==1)
		{my.STATE = 1;}
		
		if (my.STATE ==1)
		{
			//define key inputs
			movedir.x = (key_cuu-key_cud)*(1+key_shift*2);
			movedir.y = (key_ctrl-key_ins);
			
			//define mouse motion
			//rotdir.pan = -mouse_force.x;
			rotdir.pan = (key_cul-key_cur); 
			
			//calculate speed
			movedir.x *= movespeed*time_step;
			movedir.y *= movespeed*time_step;
			
			//calculate speed of movement
			rotdir.pan *= turnspeed*time_step;
			
			//rotate and move
			vec_add(my.pan, rotdir);
			c_move(my, vector(movedir.x, movedir.y, 0), nullvector, GLIDE|IGNORE_PASSABLE);
			var distance = (key_cuu-key_cud | key_ctrl-key_ins)*15*time_step;
				if (key_cuu ==1 | key_cud ==1) //walk forward-backward
				{
					my.ANIMATION += 1*distance;
					ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE);
				}
				if (key_ctrl ==1 | key_ins ==1) //strafe left-right
				{
					my.ANIMATION += 1*distance;
		      	ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE);
		      }
		      if (key_cuu ==1 & key_ins ==1)
				{
					my.ANIMATION -= 1*distance;
		      	ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE);
		      }
		      if (key_cuu ==1 & key_ctrl ==1)
				{
					my.ANIMATION -= 1*distance;
		      	ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE);
		      }
		      if (key_cud ==1 & key_ins ==1)
				{
					my.ANIMATION -= 1*distance;
		      	ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE);
		      }
		      if (key_cud ==1 & key_ctrl ==1)
				{
					my.ANIMATION -= 1*distance;
		      	ent_animate(me,"walk",my.ANIMATION,ANM_CYCLE);
		      }
      }
      
		
		//check distance to ground
		grounddist = c_trace(my.x, vector(my.x, my.y, my.z-10000), IGNORE_ME|IGNORE_PASSABLE)-feedheight;
		if(grounddist > 0 || movedir.z < 0)
		{
			//gravity acceleration
			movedir.z += fallacc*time_step;
		}else
		{
			movedir.z = 0;
		}
		
		//apply gravity
		my.z -= minv(movedir.z*time_step, grounddist);
		
		if(grounddist-minv(movedir.z*time_step, grounddist) == 0)
		{
			if(key_space == 1)
					{my.STATE = 3;}
					if (my.STATE ==3)
					{
						while (1) 
						{ 
							ent_animate(my,"jump",jump_percentage, 0);
							jump_percentage += 7 * time_step; 
							wait (1); 
						}
					
						if(grounddist-minv(movedir.z*time_step, grounddist) == 0)
							{
							//jump

								movedir.z = -jumpacc;
							}
						
					}


		}
		
		if (my.STATE == 2)
		{
		my.pan += (key_cul-key_cur)*20*time_step; 
		var stand_percentage;
		ent_animate(my,"stand",stand_percentage, ANM_CYCLE);
		stand_percentage += 2 * time_step;
		wait(1);
		}
		
		wait(1);
	}
}


Posted By: Pappenheimer

Re: Issue scripting jump animation - 06/09/11 18:55

Did you set the state back to 1 or what ever is needed for the other movements?
Posted By: emo10001

Re: Issue scripting jump animation - 06/09/11 19:56

I'm not sure where I would do that.
Posted By: emo10001

Re: Issue scripting jump animation - 06/09/11 20:51

Hmm...I'm pretty stuck. I've been messing with this for hours...still can't seem to get it. I'm sure it's something easy. At least it seems it shouldn't be that hard to do.
Posted By: Pappenheimer

Re: Issue scripting jump animation - 06/09/11 21:08

Did you try adding "my.STATE = 1;" in the part of the jumping?
Code:
if(grounddist-minv(movedir.z*time_step, grounddist) == 0)
		{
							//jump
			movedir.z = -jumpacc;
			my.STATE = 1;
		}


If that doesn't do the trick, try to rebuild the code from scratch, thinking about what is the beginning and what is to be add next, adding one thing at a time, testing, add another, testing, and so on.
Posted By: emo10001

Re: Issue scripting jump animation - 06/09/11 21:26

Yeah, if I put my.STATE =1; there....nothing changes...still runs the jump animation one time and then I can't do anything else....all animations stop completely. It won't even go back to the "stand" animation (which is my.STATE 2). The level doesn't seem to lock up...but the player does.
Posted By: emo10001

Re: Issue scripting jump animation - 06/12/11 19:33

Ok....still using modified "Improve Player Movement" script from the wiki...I put the jump animation in a function. I can now get the jump animation to play all the way through....as long at the player is not moving otherwise. But if I'm moving backwards or forwards...and/or strafing...the walk animation overrides the jump animation. I've tried "if/else if"ing the button pushes to include the space bar...but to no avail.

Anyone have any ideas...or a suggestion to try?

I'm just using a terrain and the guard model...and this as my script:

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <mtlFX.c>

#define STATE     skill1
#define ANIMATION skill2
///////////////////////////////

function main()
{
	//video_screen = 1;
	detail_size = 2;
	level_load("testgame.wmb");

}

function camera_follow(ENTITY* ent)
{
	while(1) 
	{
		vec_set(camera.x,vector(-150,10,50));  // camera position relative to the player      
		vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
		vec_add(camera.x,ent.x);      // add player position
		vec_set(camera.pan,vector(ent.pan,-10,0)); // look in player direction, slighty down      
		wait(1);
	}
}

function jump()
{
	//movedir.z = -jumpacc;
	var jump_percentage = 0;
	while(jump_percentage < 100)
	{
		ent_animate(my,"jump",jump_percentage,ANM_CYCLE);
		jump_percentage += 10*time_step;
		wait(1);
	}
}
	
action move_guard()
{
	camera_follow(me);
	
	//Parameter
	var movespeed = 10;
	var turnspeed = 10;
	var fallacc = 3.68;
	var jumpacc = 15;
	
	//Temporary
	VECTOR movedir;
	vec_set(movedir, vector(0, 0, 0));
	ANGLE rotdir;
	vec_set(rotdir, vector(0, 0, 0));
	var grounddist;
	
	//determine player height
	c_setminmax(my);
	wait(1);
	var feedheight = -my.min_z;
	
	//adjust bounding box
	my.min_x *= 0.7;
	my.min_y *= 0.8;
	my.min_z = 0;
	my.max_x *= 0.7;
	my.max_y *= 0.8;
	my.max_z *= 0.8;
	
	proc_mode = PROC_EARLY;

	while(1)
	{
//		//define key inputs
		movedir.x = key_cuu-key_cud; //*(1+key_shift*2); FORWARD-BACKWARD
		movedir.y = key_ctrl-key_ins; // STRAFE LEFT-RIGHT
			                         
//		//calculate speed
		movedir.x *= movespeed*time_step;
		movedir.y *= movespeed*time_step;		

		my.pan += (key_cul-key_cur)*5*time_step;  // TURN/ROTATE LEFT-RIGHT
		
		c_move(my,vector(movedir.x, movedir.y, 0), nullvector, GLIDE|IGNORE_PASSABLE);
		if(key_cuu | key_cud)
		{
			my.ANIMATION += 1*movedir.x;
			ent_animate(my,"walk",my.ANIMATION,ANM_CYCLE);
		}
		else if(key_ins | key_ctrl)
		{
			my.ANIMATION += 1*movedir.y;
			ent_animate(my,"walk", my.ANIMATION,ANM_CYCLE);
		}
		else if(key_cuu & key_ctrl | key_cuu & key_ins)
		{
			my.ANIMATION -= 1*movedir.x;
			ent_animate(my,"walk", my.ANIMATION,ANM_CYCLE);
		}
		else if(key_cud & key_ctrl | key_cud & key_ins)
		{
			my.ANIMATION -= 1*movedir.x;
			ent_animate(my,"walk", my.ANIMATION,ANM_CYCLE);
		}
		
		//check distance to ground
		grounddist = c_trace(my.x, vector(my.x, my.y, my.z-10000), IGNORE_ME|IGNORE_PASSABLE)-feedheight;
		if(grounddist > 0 || movedir.z < 0)
		{
			//gravity acceleration
			movedir.z += fallacc*time_step;
		}else
		{
			movedir.z = 0;
		}
		
		//apply gravity
		my.z -= minv(movedir.z*time_step, grounddist);
		
		if(grounddist-minv(movedir.z*time_step, grounddist) == 0)
		{
			//jump
			if(key_space)
			{
					jump();
					movedir.z = -jumpacc;
			}
		}
//
//	
//	if (my.STATE = 1)
//	{
//		var stand_percentage;
//		ent_animate(my,"stand",stand_percentage, ANM_CYCLE);
//		stand_percentage += 2 * time_step;
//	}
		

		wait(1);	
	}

}


Posted By: emo10001

Re: Issue scripting jump animation - 06/12/11 23:20

Ugh....ok....so I took the jump funtion out....added a state. And now...it runs through the entire jump animation (good!), but...doesn't actually raise the model up and down (the actual jump) until the animation is finished. Sooooo close...

Any ides....Beuller?

Here's the state:

Code:
if(my.STATE == 4)
{
	var jump_percentage = 0;
	while(jump_percentage < 100)
	{
		movedir.z = -jumpacc;
		ent_animate(my,"jump",jump_percentage,0);
		jump_percentage += 10*time_step;
		wait(1);
	}
	if(!key_space)
	{my.STATE = 1;}
}


Posted By: Pappenheimer

Re: Issue scripting jump animation - 06/13/11 11:32

Replace the 'while' with if and remove the 'wait(1);'.
Posted By: emo10001

Re: Issue scripting jump animation - 06/13/11 13:49

Yeah...I've been trying all kinds of combinations. If I replace "while" with "if", the animation stops after the first frame and if I'm in the process of walking also, goes back to the walking animation before the jump is finished. If I take out the "wait", it goes through half the animation and my player "climbs" higher and higher until key_space is released. Very strange.

I know it's got to be some combination of something...
Posted By: MrGuest

Re: Issue scripting jump animation - 06/13/11 15:50

just add the movement into the your animation while loop
Posted By: emo10001

Re: Issue scripting jump animation - 06/13/11 17:37

Yeah that's what I've done now (at least I think I've done) My state now looks like this:

Code:
if(my.STATE == 4)
		{
			var jump_percentage = 0;
			while(jump_percentage < 100)
			{
				movedir.z = -jumpacc;
				ent_animate(my,"jump",jump_percentage,0);
				jump_percentage += 10*time_step;
				wait(1);
			}
			if(!key_space)
			{
				my.STATE = 1;
			}
		}



The "movedir.z = -jumpacc;" is the actual jump code. But I'm getting the same results. It runs through the jump animation first, then raises and lowers the player, instead of doing them both at the same time.
Posted By: MrGuest

Re: Issue scripting jump animation - 06/13/11 21:25

c_move is the bit which moves the player, you'll need that in there too along with any other input you allow while jumping
Posted By: emo10001

Re: Issue scripting jump animation - 06/26/11 17:04

Ok...I'm bumping this as I still can't get this to work. I'm really struggling with this and I feel like I'm REALLY close.

Everything is working correctly now except for the fact that, when I press the Space Bar and the code moves to STATE 4, the model goes through the jumping animation first, and THEN the model actually moves up and down. I still can't get them to both happen at the same time.

I understand c_move and what it does, and it's in the code at line 77, however, if I understand this correctly, it's NOT what's actually making the player move up and down...that bit is the "movedir.z = -jumpacc;" part of the code...right?

Keep in mind, this is using the "Improved Player Movement" code from the wiki...all I'm trying to do is add animations for the 3rd party camera.
Html:
http://www.opserver.de/wiki/index.php/Improved_Player_Movement



Why this isn't working...is really boggling me. Any help would be so appreciated!

Here's my entire code:

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <mtlFX.c>

#define STATE skill1
#define ANIMATION skill2
///////////////////////////////

function main()
{
	//video_screen = 1;
	detail_size = 2;
	level_load("templatetest.WMB");
	wait(2);
}

function camera_follow(ENTITY* ent)
{
	while(1) 
	{
		vec_set(camera.x,vector(-150,10,50));  // camera position relative to the player      
		vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
		vec_add(camera.x,ent.x);      // add player position
		vec_set(camera.pan,vector(ent.pan,-13,0)); // look in player direction, slighty down      
		wait(1);
	}
}

action player_move()
{
	camera_follow(me);
	
	if(key_cuu ==0 | key_cud ==0 | key_cul ==0 | key_cur ==0 | key_ins ==0 | key_ctrl ==0 | key_space ==0)
	{my.STATE = 1;}
	
	//Parameter
	var movespeed = 10;
	var turnspeed = 10;
	var fallacc = 3.68;
	var jumpacc = 20;
	
	//Temporary
	VECTOR movedir;
	vec_set(movedir, vector(0, 0, 0));
	ANGLE rotdir;
	vec_set(rotdir, vector(0, 0, 0));
	var grounddist;
	
	//determine player height
	c_setminmax(my);
	wait(1);
	var feedheight = -my.min_z;
	
	//adjust bounding box
	my.min_x *= 0.4;
	my.min_y *= 0.8;
	my.min_z = 0;
	my.max_x *= 0.4;
	my.max_y *= 0.8;
	my.max_z *= 0.8;
	
	proc_mode = PROC_EARLY;

	while(1)
	{
		//define key inputs
		movedir.x = key_cuu-key_cud; //*(1+key_shift*2); FORWARD-BACKWARD
		movedir.y = key_ctrl-key_ins; // STRAFE LEFT-RIGHT
			                         
		//calculate speed
		movedir.x *= movespeed*time_step;
		movedir.y *= movespeed*time_step;		

		my.pan += (key_cul-key_cur)*5*time_step;  // TURN/ROTATE LEFT-RIGHT
		
		c_move(my,vector(movedir.x, movedir.y, 0), nullvector, GLIDE|IGNORE_PASSABLE);
		if(key_cuu | key_cud)
		{
			my.STATE = 2;
		}
		if(key_ins | key_ctrl)
		{
			my.STATE = 3;
		}
		if(key_cuu & key_ctrl | key_cuu & key_ins)
		{
			my.STATE = 2;
		}
		if(key_cud & key_ctrl | key_cud & key_ins)
		{
			my.STATE = 2;
		}
		
		//check distance to ground
		grounddist = c_trace(my.x, vector(my.x, my.y, my.z-10000), IGNORE_ME|IGNORE_PASSABLE)-feedheight;
		if(grounddist > 0 || movedir.z < 0)
		{
			//gravity acceleration
			movedir.z += fallacc*time_step;
		}else
		{
			movedir.z = 0;
		}
		
		//apply gravity
		my.z -= minv(movedir.z*time_step, grounddist);
		
		if(grounddist-minv(movedir.z*time_step, grounddist) == 0)
		{
			//jump
			if(key_space)
			{
				my.STATE = 4;
			}

		}
	
		if(my.STATE == 1)
		{
			var stand_percentage;
			ent_animate(my,"stand",stand_percentage, ANM_CYCLE);
			stand_percentage += 2 * time_step;

		}
		
		if(my.STATE == 2)
		{
			my.ANIMATION += 1*movedir.x;
			ent_animate(my,"walk",my.ANIMATION,ANM_CYCLE);
			if(!key_cuu | !key_cud | !key_cul | !key_cur | !key_ins | !key_ctrl | !key_space)
			{my.STATE = 1;}
		}
		
		if(my.STATE == 3)
		{
			my.ANIMATION += 1*movedir.y;
			ent_animate(my,"walk",my.ANIMATION,ANM_CYCLE);
			if(!key_cuu | !key_cud | !key_cul | !key_cur | !key_ins | !key_ctrl | !key_space)
			{my.STATE = 1;}
		}
		
		if(my.STATE == 4)
		{
			var jump_percentage = 0;
			while(jump_percentage < 100)
			{
				movedir.z = -jumpacc;
				ent_animate(my,"jump",jump_percentage,0);
				jump_percentage += 10*time_step;
				wait(1);
			}
			if(!key_space)
			{
				my.STATE = 1;
			}
		}
		
	wait(1);	
	}

}


Posted By: emo10001

Re: Issue scripting jump animation (BIG IMPROVEMENT!!! ) - 06/26/11 18:31

Ok! I just made a major step! Thank you Mr. Guest for reminding me to keep looking at c_move. I added it a second time in my STATE 4. Made the z vector the "movedir.z". Then had to add another while loop for the jump_percentage.

It's not perfect...but good enough for now. My only issue now is that the jump animation finishes before the player get's back to the ground. It actually finishes as the top of the jump, and the the player drops back down with either the walking animation (if the player is walking and jumping) or the standing animation (if the player was just standing and then jumping).

If anyone has any suggestions on getting the jump animation to finish as the player is landing...instead of at the top of the jump...please feel free to suggest!

Here's the new code:

Code:
///////////////////////////////
#include <acknex.h>
#include <default.c>
#include <mtlFX.c>

#define STATE skill1
#define ANIMATION skill2
///////////////////////////////

function main()
{
	//video_screen = 1;
	detail_size = 2;
	level_load("templatetest.WMB");
	wait(2);
}

function camera_follow(ENTITY* ent)
{
	while(1) 
	{
		vec_set(camera.x,vector(-150,10,50));  // camera position relative to the player      
		vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
		vec_add(camera.x,ent.x);      // add player position
		vec_set(camera.pan,vector(ent.pan,-13,0)); // look in player direction, slighty down      
		wait(1);
	}
}

action player_move()
{
	camera_follow(me);
	
	if(key_cuu ==0 | key_cud ==0 | key_cul ==0 | key_cur ==0 | key_ins ==0 | key_ctrl ==0 | key_space ==0)
	{my.STATE = 1;}
	
	//Parameter
	var movespeed = 10;
	var turnspeed = 10;
	var fallacc = 3.68;
	var jumpacc = 5;

	
	//Temporary
	VECTOR movedir;
	vec_set(movedir, vector(0, 0, 0));
	ANGLE rotdir;
	vec_set(rotdir, vector(0, 0, 0));
	var grounddist;
	
	//determine player height
	c_setminmax(my);
	wait(1);
	var feedheight = -my.min_z;
	
	//adjust bounding box
	my.min_x *= 0.4;
	my.min_y *= 0.8;
	my.min_z = 0;
	my.max_x *= 0.4;
	my.max_y *= 0.8;
	my.max_z *= 0.8;
	
	proc_mode = PROC_EARLY;

	while(1)
	{
		//define key inputs
		movedir.x = key_cuu-key_cud; //*(1+key_shift*2); FORWARD-BACKWARD
		movedir.y = key_ctrl-key_ins; // STRAFE LEFT-RIGHT
			                         
		//calculate speed
		movedir.x *= movespeed*time_step;
		movedir.y *= movespeed*time_step;		

		my.pan += (key_cul-key_cur)*5*time_step;  // TURN/ROTATE LEFT-RIGHT
		
		c_move(my,vector(movedir.x, movedir.y, 0), nullvector, GLIDE|IGNORE_PASSABLE);
		if(key_cuu | key_cud)
		{
			my.STATE = 2;
		}
		if(key_ins | key_ctrl)
		{
			my.STATE = 3;
		}
		if(key_cuu & key_ctrl | key_cuu & key_ins)
		{
			my.STATE = 2;
		}
		if(key_cud & key_ctrl | key_cud & key_ins)
		{
			my.STATE = 2;
		}
		
		//check distance to ground
		grounddist = c_trace(my.x, vector(my.x, my.y, my.z-10000), IGNORE_ME|IGNORE_PASSABLE)-feedheight;
		if(grounddist > 0 || movedir.z < 0)
		{
			//gravity acceleration
			movedir.z += fallacc*time_step;
		}else
		{
			movedir.z = 0;
		}
		
		//apply gravity
		my.z -= minv(movedir.z*time_step, grounddist);
		
		if(grounddist-minv(movedir.z*time_step, grounddist) == 0)
		{
			//jump
			if(key_space)
			{
				my.STATE = 4;
			}

		}
	
		if(my.STATE == 1)
		{
			var stand_percentage;
			ent_animate(my,"stand",stand_percentage, ANM_CYCLE);
			stand_percentage += 2 * time_step;

		}
		
		if(my.STATE == 2)
		{
			my.ANIMATION += 1*movedir.x;
			ent_animate(my,"walk",my.ANIMATION,ANM_CYCLE);
			if(!key_cuu | !key_cud | !key_cul | !key_cur | !key_ins | !key_ctrl | !key_space)
			{my.STATE = 1;}
		}
		
		if(my.STATE == 3)
		{
			my.ANIMATION += 1*movedir.y;
			ent_animate(my,"walk",my.ANIMATION,ANM_CYCLE);
			if(!key_cuu | !key_cud | !key_cul | !key_cur | !key_ins | !key_ctrl | !key_space)
			{my.STATE = 1;}
		}
		
		if(my.STATE == 4)
		{
			var jump_percentage = 0;
			while(jump_percentage < 100)
			{
				movedir.z = jumpacc*time_step;
				
				c_move(my,vector(movedir.x, movedir.y, movedir.z), nullvector, GLIDE|IGNORE_PASSABLE);
				my.pan += (key_cul-key_cur)*5*time_step;
				
				ent_animate(my,"jump",jump_percentage,0);
				jump_percentage += 10*time_step;
				
				wait(1);
			}
			while(jump_percentage > 1)
			{
				jump_percentage = 0;
				my.STATE = 1;
				wait(1);
			}
		}
		
	wait(1);	
	}

}


© 2024 lite-C Forums