Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AemStones, AndrewAMD, gamers, Kingware), 1,679 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Animation problem in my code #364688
03/20/11 00:00
03/20/11 00:00
Joined: Jun 2010
Posts: 71
L
LawnmowerMan Offline OP
Junior Member
LawnmowerMan  Offline OP
Junior Member
L

Joined: Jun 2010
Posts: 71
This is my function for the player animation but I have a problem that animation speed up and slow down by themselves. I do not know where I made a mistake, please if anyone can help me.
I hope that some of the more experienced guys can help me blush

Code:
function player_animations(){
	if(my.state_player == stand)
	{
 		while (key_cuu == 0 && key_cud == 0 && key_cul == 0 && key_cur == 0) // play the "stand" animation if force keys not pressed
		{
			ent_animate (me, "stand", my.skill96, anm_cycle);
			my.skill96 += 1 * time_step;
			my.skill96 %= 100;
			wait (1); 
		}
		my.skill92 = 0;
		while(my.skill92 < 100){
			ent_animate (me, "stand", my.skill92, anm_cycle);
			ent_blend("walk", 0, my.skill42); // blend "wait" into "walk"
			my.skill92 += 10 * time_step;
			wait(1);
		}
		while (1){
			ent_animate (me, "walk", my.skill97, anm_cycle);
			my.skill97 += 1 * time_step;
			my.skill97 %= 100;
			wait (1); 
		} 	
 	}
	if(my.state_player == walk)
	{
 		while (key_cuu == 1 || key_cud == 1 || key_cul == 1 || key_cur == 1) // play the "walk" animation until the player relase force keys
		{
			ent_animate (me, "walk", my.skill96, anm_cycle);
			my.skill96 += 1 * time_step;
			my.skill96 %= 100;
			wait (1); 
		}
		my.skill42 = 0;
		while(my.skill92 < 100){
			ent_animate (me, "walk", my.skill92, anm_cycle);
			ent_blend("stand", 0, my.skill92); // blend "stand" into "walk"
			my.skill92 += 10 * time_step;
			wait(1);
		}
		while (1){
			ent_animate (me, "stand", my.skill97, anm_cycle);
			my.skill97 += 1 * time_step;
			my.skill97 %= 100;
			wait (1); 
		}
 	}
 }



Re: Animation problem in my code [Re: LawnmowerMan] #364742
03/20/11 13:19
03/20/11 13:19
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
I guess that you call the function player_animations in a while-loop already, right? Then, you should replace all the whiles with ifs and remove the waits - just to get proper reliable code.

What is odd, too, are the different skills used for counting up the percents for the animations, maybe, there's something mixed up.

Re: Animation problem in my code [Re: Pappenheimer] #364759
03/20/11 16:43
03/20/11 16:43
Joined: Jun 2010
Posts: 71
L
LawnmowerMan Offline OP
Junior Member
LawnmowerMan  Offline OP
Junior Member
L

Joined: Jun 2010
Posts: 71
Hi Pappenheimer!

Yes this function is already in whille loop. I'm trying to make the transition between the two animation walk and stand, and I tried to take example from AUM61 but that code is not clear to me, like you say strange is we have different skills for animations? Maybe this example is not good for my case. I need advice how simply make blend betwen two animations. I really stuck with this frown. Here is my animation code:



Code:
function player_animations(){
	my.animation %= 100;
	if (my.animation < 0) { my.animation += 100; }
	
	if (my.state_player == stand) {
		my.animation += 2 * time_step;
		ent_animate (my, "stand", my.animation, ANM_CYCLE);
	} 
	if (my.state_player == run) {
		my.animation += 8.4 * time_step;
		ent_animate (my, "walk", my.animation, ANM_CYCLE); 
	}
}



Re: Animation problem in my code [Re: LawnmowerMan] #364764
03/20/11 17:20
03/20/11 17:20
Joined: Dec 2008
Posts: 1,660
North America
Redeemer Offline
Serious User
Redeemer  Offline
Serious User

Joined: Dec 2008
Posts: 1,660
North America
Hi,

First of all, this what your original code should look like.

This is your original animation code:
Code:
function player_animations(){
	my.animation %= 100;
	if (my.animation < 0) { my.animation += 100; }
	
	if (my.state_player == stand) {
		my.animation += 2 * time_step;
		ent_animate (my, "stand", my.animation, ANM_CYCLE);
	} 
	if (my.state_player == run) {
		my.animation += 8.4 * time_step;
		ent_animate (my, "walk", my.animation, ANM_CYCLE); 
	}
}


And this is what it should look like:
Code:
function player_animations(){
	if (my.animation > 100) my.animation -= 100;

	if (my.state_player == stand) {
		my.animation += 2 * time_step;
		ent_animate (my, "stand", my.animation, ANM_CYCLE);
	} 
	if (my.state_player == run) {
		my.animation += 8.4 * time_step;
		ent_animate (my, "walk", my.animation, ANM_CYCLE); 
	}
}



To blend between the animations, you need to use ent_blendframe().

Hope that helps. wink

Last edited by Redeemer; 03/20/11 17:22.

Eats commas for breakfast.

Play Barony: Cursed Edition!
Re: Animation problem in my code [Re: Redeemer] #364769
03/20/11 17:40
03/20/11 17:40
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
This
my.animation %= 100;
is the the same like this
if (my.animation > 100) my.animation -= 100;

It simply assures that the counter restarts from zero when reaching 100.

I recommend a simple test code where you start the animation and the blending by a key to experiment with it.

The following part of your first code shows the blending in the first while loop where the skill42 is the percentage of the blending of the blended animation, "walk". This value has to be counted up to 100, and then you have to switch to animate the "walk" animation, only, instead of blending it with the "stand" animation.
Code:
while(my.skill92 < 100){
			ent_animate (me, "stand", my.skill92, anm_cycle);
			ent_blend("walk", 0, my.skill42); // blend "wait" into "walk"
			my.skill92 += 10 * time_step;
			wait(1);
		}
		while (1){
			ent_animate (me, "walk", my.skill97, anm_cycle);



Re: Animation problem in my code [Re: Pappenheimer] #364780
03/20/11 19:31
03/20/11 19:31
Joined: Jun 2010
Posts: 71
L
LawnmowerMan Offline OP
Junior Member
LawnmowerMan  Offline OP
Junior Member
L

Joined: Jun 2010
Posts: 71
Thank you guys but I will kill myself or I will break my PC mad . I think i going on wrong way. This code from George only play walk animation and whan we press space key animation blend to stand and then stop. I do not see any way how to use this in my code.

Code:
action walk_to_stand(){
	player = me;
	player_camera();
	
	while (key_space == 0)
	{
		ent_animate (me, "walk", my.skill46, anm_cycle);
		my.skill46 += 10 * time_step;
		my.skill46 %= 100;
		wait (1); 
	}
	my.skill42 = 0;
	while(my.skill42 < 100)
	{
		ent_animate (me, "walk", my.skill42, anm_cycle);
		ent_blend("stand", 0, my.skill42);
		my.skill42 += 5 * time_step;
		wait(1);
	}
	while (1)
	{
		ent_animate (me, "stand", my.skill47, anm_cycle);
		my.skill47 += 1 * time_step;
		my.skill47 %= 100;
		wait (1); 
	}
	
}



If there's a better example? This is very difficult for me because I am not an experienced programmer. Whether there is any other function for c-script except ent_blend?


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