Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
2 registered members (steyr, alibaba), 534 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Blending [looks like no one have the unswer] #317990
04/04/10 05:14
04/04/10 05:14
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
Yesterday, I've started the same topic in Lite-C Programming, but looks like no one can unswer frown So thats why I'm making new topic here. My weapons have many animations (run,idle,hoslster,draw,shoot,reload,aim), so I need smooth changing bettwen animations, thats why I want to use ent_blend, from Wiki I got and changed this script to my own needs:
ANIMATIONS.C
Code:
/*
call in player while loop
handle_animation(1);
*/

#define nullframe	-2
#define blend		-1
#define stand		 0
#define run			 1
#define shoot	 2
#define reload	 3
#define draw	 4
#define holster	 5

#define animate			skill31
#define animate2			skill32
#define animblend			skill33
#define currentframe		skill34
#define blendframe		skill35

function handle_animation(var animation_speed) 
{
	if(animation_speed <= 0)	animation_speed = 1; 
	if(my.animblend != blend && my.blendframe != nullframe) { my.animate2 = 0; my.animblend = blend; }
	if(my.animblend == blend) 
	{
		if		 (my.currentframe == stand)		ent_animate(my, "idle",    my.animate, ANM_CYCLE); 
		else if(my.currentframe == run)			ent_animate(my, "run",      my.animate, ANM_CYCLE);
		else if(my.currentframe == shoot)	ent_animate(my, "shoot", my.animate,0);
		else if(my.currentframe == reload)	ent_animate(my, "reload", my.animate,0);
		else if(my.currentframe == draw)	ent_animate(my, "draw", my.animate,0);
		else if(my.currentframe == holster)	ent_animate(my, "holster", my.animate,0);
		
		if		 (my.blendframe == stand)		ent_blend("idle",0,my.animate2);
		else if(my.blendframe == run)			ent_blend("run",0,my.animate2);
		else if(my.blendframe == shoot)	ent_blend("shoot",0,my.animate2);
		else if(my.blendframe == reload)	ent_blend("reload",0,my.animate2);
		else if(my.blendframe == draw)	ent_blend("draw",0,my.animate2);
		else if(my.blendframe == holster)	ent_blend("holster",0,my.animate2);
		my.animate2 += 45 * time_step;
		if(my.animate2 >= 100) 
		{
			my.animate = 0;
			my.animblend = my.blendframe;
			my.blendframe = nullframe;
		}
	}
	//
	switch(my.animblend)
	{
		case stand:
			ent_animate(my,"idle",my.animate,ANM_CYCLE);
			my.animate += 2 * animation_speed * time_step;
			my.animate %= 100;
			my.currentframe = stand;
			break;
		case run:
			ent_animate(my,"run",my.animate,ANM_CYCLE);
			my.animate += 10 * animation_speed * time_step;
			my.animate %= 100;
			my.currentframe = run;
			break;
		case shoot:
			ent_animate(my,"shoot",my.animate,0);
			my.animate += 20 * animation_speed * time_step;
			my.currentframe = shoot;
			if(my.animate >= 100) 
			{
				ent_animate(my,"shoot",100,0);
				my.animate = 100;
				my.blendframe = stand;
				if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d)) 
				{
					if(key_shift == 1)		my.blendframe = run;
				}
			}
			break;
		case reload:
			ent_animate(my,"reload",my.animate,0);
			my.animate += 15 * animation_speed * time_step;
			my.currentframe = reload;
			if(my.animate >= 100) 
			{
				ent_animate(my,"reload",100,0);
				my.animate = 100;
				my.blendframe = stand;
				if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d)) 
				{
					if(key_shift == 1)		my.blendframe = run;
				}
			}
			break;
		case draw:
			ent_animate(my,"draw",my.animate,0);
			my.animate += 10 * animation_speed * time_step;
			my.currentframe = draw;
			if(my.animate >= 100) 
			{
				ent_animate(my,"draw",100,0);
				my.animate = 100;
				my.blendframe = stand;
				if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d)) 
				{
					if(key_shift == 1)		my.blendframe = run;
				}
			}
			break;
		case holster:
			ent_animate(my,"holster",my.animate,0);
			my.animate += 15 * animation_speed * time_step;
			my.currentframe = holster;
			if(my.animate >= 100) 
			{
				ent_animate(my,"holster",100,0);
				my.animate = 100;
				my.blendframe = stand;
				if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d)) 
				{
					if(key_shift == 1)		my.blendframe = run;
				}
			}
			break;
	}
	if(my.animblend != blend && my.blendframe != nullframe) 		{ my.animate2 = 0; my.animblend = blend; }
}

function main_anim()
{
	if(vec_dist (player1_pos.x, player2_pos.x) != 0 && (key_w || key_s || key_a || key_d) && force_run > 5 && climb == 0 && crawling == 0) 
	{
		if(my.animblend == stand) 
		{
			if(key_shift == 1)	my.blendframe = run;
		}
	} 
	else
	{
		if(my.animblend > stand) 
		{	
			my.blendframe = stand;
		}
	}
}


Here is how I'm tring to use it:
Code:
action v_usp()
{
	weapon = me;
	set(my,ZNEAR);
	while(me == weapon)
	{
		if ((mouse_left ==1)&&(usp_rdy ==1))
		{
			if (usp_clip > 0)
			{
				usp_shoot(1);
				while(mouse_left){wait(1);}
			}
		}
		main_anim();
		handle_animation(1);
		wait(1);
	}
}

function usp_shoot(t)
{
	if (t ==1)
	{
		snd_play(deagle_shot_snd,100,0);
                my.blendframe = shoot;
                my.animate2 = 0;
                my.animblend = blend;
		ent_create(bullet_mdl,camera.x,bullet);
	}
}



When I try to do this way, there ia only runing and idle animations are working frown but how do I add shoot,reload,draw etc. Really need your help. May be there is an other way to make smooth animation changings?


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Blending [looks like no one have the unswer] [Re: 3run] #317992
04/04/10 05:31
04/04/10 05:31
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
I use blending in some of my games too, I forgot the exact code but you must have separate variable for each blend like blend from run_to_idle, run_to_aim, run_to_die, aim_to_die etc... I know it such a pain to do but I cant think any more way to do that.

Re: Blending [looks like no one have the unswer] [Re: bart_the_13th] #317993
04/04/10 05:40
04/04/10 05:40
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
Can you post some example, from your projects? Please I really need this


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Blending [looks like no one have the unswer] [Re: 3run] #317995
04/04/10 06:06
04/04/10 06:06
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
I'm far from my PC right now laugh
Maybe tomorrow I'll post it...

Re: Blending [looks like no one have the unswer] [Re: bart_the_13th] #317997
04/04/10 06:32
04/04/10 06:32
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
Thank you laugh I'll wait for your help))


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Blending [looks like no one have the unswer] [Re: 3run] #318223
04/06/10 07:21
04/06/10 07:21
Joined: Aug 2008
Posts: 482
B
bart_the_13th Offline
Senior Member
bart_the_13th  Offline
Senior Member
B

Joined: Aug 2008
Posts: 482
Ok, here's the code. I have a run animation, walk animation and stand animation for the lower body, and run, walk stand, reload and shoot animation for upper body so it may seems complicated(since I use 1 model)
Code:
blendwalk+=time_step*30;
		if(blendwalk>100) blendwalk=100;
		
		blendrun+=time_step*30;
		if(blendrun>100) blendrun=100;

		blendshoot+=time_step*30;
		if(blendshoot>100) blendshoot=100;

		if(key_shift == 1 && aim==0) //is running
		{
			if(run==0) blendrun=0;
			run=1;
			vec_scale(speed.x,2);
		}
		else
		{
			if(run==1) blendrun=0;
			run=0;
		}

		result=c_move(me, nullvector, vector(-speed.x*move_dest.x,-speed.y*move_dest.y,0), IGNORE_PASSABLE | GLIDE);

		if(result>0) //is moving
		{
			if(aim==0) //is not shooting
			{
				if(key_shift) // is not running
				{
					ent_animate(me,run_str,total_ticks*5,ANM_CYCLE);
				}
				else
				{
					ent_animate(me,"walk",total_ticks*5,ANM_CYCLE);
				}
				if(blendshoot<100) ent_blend("shoot",0,100-blendshoot);//blend from shooting to walking/running
			}
			else
			{
				ent_animate(me,"shoot",my.recoil_effect,ANM_CYCLE);
				if(blendshoot<100)
				{
					if(key_shift)	ent_blend(run_str,total_ticks*5,100-blendshoot);//blend from running to shooting
					else		ent_blend("walk",total_ticks*5,100-blendshoot); //blend from walking to shooting
				}
			}
			if(my.reloading>0) //is reloading
			{
				if(my.reloading<10)	ent_blend(reload_str,100-my.reloading,(my.reloading)*10);
				if(my.reloading>=10 && my.reloading<=80)	ent_animate(me,reload_str,100-my.reloading,ANM_CYCLE);
				if(my.reloading>80)	ent_blend(reload_str,100-my.reloading,100-(my.reloading%20)*5);
			}

			if(key_shift && aim==0)	ent_animate(me,"legrun",total_ticks*10,ANM_CYCLE|ANM_ADD);
			else	ent_animate(me,"legwalk",100-(total_ticks*5)%100,ANM_CYCLE|ANM_ADD);

			if(blendmove<100)
			{
				if(aim==0)	ent_blend("stand",total_ticks*5,100-blendmove);//blend from walk/run to stand
				if(aim==1)	ent_blend("shoot",0,100-blendmove);//blend from walk/run to shoot
			}
		}
		else
		{
			if(aim==0)
			{
				ent_animate(me,"stand",0,0);
				if(blendshoot<100)	ent_blend("shoot",0,100-blendshoot);//blend from stand to shoot
			}
			else
			{
				ent_animate(me,"shoot",my.recoil_effect+=1,ANM_CYCLE);
				if(blendshoot<100)	ent_blend("stand",0,100-blendshoot);//blend from shoot to stand
			}
			if(my.reloading>0)
			{
				if(my.reloading<10)	ent_blend(reload_str,100-my.reloading,(my.reloading)*10);
				if(my.reloading>=10 && my.reloading<=80)	ent_animate(me,reload_str,100-my.reloading,ANM_CYCLE);
				if(my.reloading>80)	ent_blend(reload_str,100-my.reloading,100-(my.reloading%20)*5);
			}
			if(blendmove<100)
			{
				if(run==1)	ent_blend(run_str,total_ticks*5,100-blendmove);//blend from shoot to run
				if(run==0)	ent_blend("walk",total_ticks*5,100-blendmove);//blend from shoot to walk
			}
		}



I'm also thinking about reducing the code using string and str_xxx but I still have no time, but I think this will give you the picture about ent_blend with some state/pose

Re: Blending [looks like no one have the unswer] [Re: bart_the_13th] #318228
04/06/10 10:40
04/06/10 10:40
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
Alternatively, use bones animation. It's much easier to blend bones than vertex animation. You'll find a workshop about bones blending in the tutorial.

Re: Blending [looks like no one have the unswer] [Re: jcl] #318350
04/07/10 09:06
04/07/10 09:06
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
I always use only bones for animations. And I don't need to blend 2 different animations together. I need smooth passage from one animation in to other. For example from run in to stand (I'm using this to animate fps weapon models). And for example shooting, if I use simple ent_animate, animations are too jerky frown and really ugly... Please be so kind and give me some snipet with witch I'll be able to have smooth passage between animations. I do use 6 different animations (run, stand, draw, reload, shoot, aim).


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Blending [looks like no one have the unswer] [Re: 3run] #318351
04/07/10 09:26
04/07/10 09:26
Joined: Jul 2000
Posts: 27,967
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,967
Frankfurt
That's why we have tutorials. People put effort into writing them. Animation blending is covered. Please honor the tutorial authors by reading their material. It is not cool to ask other people to write code snippets for you.

Re: Blending [looks like no one have the unswer] [Re: jcl] #318355
04/07/10 10:23
04/07/10 10:23
Joined: May 2009
Posts: 5,367
Caucasus
3run Offline OP
Senior Expert
3run  Offline OP
Senior Expert

Joined: May 2009
Posts: 5,367
Caucasus
I do really respect the authors of all manuals. And I know how is hard to write material such as a tutrorial. And I do know that asking for help by writing a code snippet is not that "cool" (but why then people ask George to write for them some snippets in AUM?). But I do really need help with this. I tried Original Kingdom Hearts Movement sctipt form WIKI, there is a blending between animations, but I fail by tring to adapt to my own needs frown That's why I'm asking for help...


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Page 1 of 2 1 2

Moderated by  HeelX, Spirit 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1