[ANET] Send animation

Posted By: Kronomanta

[ANET] Send animation - 12/19/09 20:58

Hi!

I try to send my animation to every clients. The animation works correctly on the own pc (host and/or client), but the others cannot see them.

I play the animation normal, then reverse:
Code:
if (key_ctrl > 0 && (my.skill42<1 || my.skill42>99))
			{
				if(my.skill44==-1){my.skill44=1;}
				else {my.skill44=-1;}
			}
			if (my.skill43==0)
			{
			
			if(my.skill44==-1 && my.skill42<100)
			{
					my.skill42+=10*time_step;
					ent_animate(my,"fly",my.skill42,null);
			}
			if(my.skill44==1 && my.skill42>0)
			{
					my.skill42-=10*time_step;
					ent_animate(my,"fly",my.skill42,null);
			}	
				enet_send_skills(enet_ent_globpointer(my),42,42,-1); //sends the new skill value
				my.skill43=1;
			}
			else
			{
				if(my.skill43 == 1) //only send the skill if the value has changed
				{
					my.skill43 = 0;
					enet_send_skills(enet_ent_globpointer(my),42,42,-1); //sends the new skill value
				}
			}




Where do I make the mistake?
Posted By: Dark_samurai

Re: [ANET] Send animation - 12/20/09 11:32

Your mistake is the following:

my.skill[42] isn't the same as my.skill42, because my.skill42 is my.skill[43] in reality. This is because my.skill[] starts with 0 and my.skillx starts with 1.

my.skill[] is the new way to access skills (the way it should be done in Lite-C). my.skillx exists only to prefent users that have to convert their codes from C-Script to Lite-C from changing all skillx calls.

enet_send_skills() needs the skill number starting by 0.

=> if you want to send my.skill42 you have to use enet_send_skills(enet_ent_globpointer(my),41,41,-1);

But I would advise you to generally use the my.skill[] notation to prefent such problems.



By the way, if you want to produce less traffic you can do sending animations much easier. The point is, that it's not important that the animation is synchronized on all participants but it's only important that the same animation is played on all hosts.
=> you can use a skill and set it to 0 for the stand animation, 1 for the run animation, 2 for the swim animation,... Everytime the animtaion changes, you save the new value in the skill and send it to all hosts. After that, the other hosts check the current value of the skill and play the according animation.

This would produce MUCH less traffic!
Posted By: Kronomanta

Re: [ANET] Send animation - 12/21/09 20:25

Yepp, you're right wink
Sending just a number for the animation is much faster wink

Thank you for the idea wink
© 2024 lite-C Forums