|
2 registered members (TipmyPip, Martin_HH),
5,303
guests, and 2
spiders. |
|
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: Easy animations
[Re: Tobias]
#326868
06/03/10 13:33
06/03/10 13:33
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
Expert
|
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
okay: You need some variables for the animation percentage. Also, you need a string where you save the actual/last animation frame. So:
//defines - lets define something to make it easier (you should do the same in your movement script (easier)
#define STAND 0
#define WALK 1
#define RUN 2
#define DUCK 3
#define JUMP 4
#define SWIM 5
//you can add more here...
//the function
function animate(ENTITY* ent) //we overgive the entity to animate - example: animate(player);
{
//Vars&Strings
var anim_per = 0;
var blend_per = 0;
STRING* anim_name = "#30"; //change the 30 if your animation names are longer
while(1) //if you don't want it to run the whole time, change the 1 to anything else...
{
//Now you need a var or a skill for you actual player movement
//You must set this var in your movement code
//I will use the player.skill1 for my example here
if(player.skill1 == STAND)
{
if(str_cmpi(anim_name, "stand") == 1) //if we already blended to the standing animation
{
ent_animate(ent, "stand", anim_per, ANM_CYCLE); //animate it in its "stand" animation
anim_per += 5 * time_step; //change 5 if you want
}
else //if we are in another animation, we will blend!
{
ent_animate(player, last_anim, anim_per, ANM_ADD); //animate him in his last position with its last animation percentage
ent_blend("stand", 0, blend_per); //blend it to the first frame of the other animation
blend_per += 5 * time_step; //change the 30 if needed
anim_per += 5 * time_step; //still animate in the old anim (change 5 if wanted)
blend_per = clamp(blend_per, 0, 100); //clamp it between 0 and 100
if(blend_per == 100) //if the blending is finished
{
str_cpy(anim_name, "stand"); //change the actual animation to the stand animation
anim_per = 0; //and change the animation percentage to 0
}
}
}
if(player.skill1 == WALK)
{
... here you do the same as for standing, but change every "stand" to "walk"
}
...and so on
wait(1);
}
you just need to copy/paste the first and change stand to your wanted animation, so you can add many to it!
|
|
|
Re: Easy animations
[Re: Rei_Ayanami]
#326965
06/03/10 21:23
06/03/10 21:23
|
Joined: May 2009
Posts: 5,377 Caucasus
3run
OP
Senior Expert
|
OP
Senior Expert
Joined: May 2009
Posts: 5,377
Caucasus
|
OK, sounds quit easy for me this way, just few questions: what is last_anim, while compiling it gets error, be cause it is undeclared. And how about non cycling animations, like SHOOT, RELOAD and DRAW. I know how to make them with ent_animate:
function shoot()
{
var shoot_percentage = 0;
while(shoot_percentage < 100)
{
ent_animate(my,NULL,0,0);
ent_animate(weapon,"shoot",shoot_percentage,ANM_ADD);
shoot_percentage += 10 * time_step;
wait (1);
}
}
How to do the samething with your snippet Rei?
|
|
|
Re: Easy animations
[Re: Rei_Ayanami]
#327126
06/04/10 18:46
06/04/10 18:46
|
Joined: Dec 2009
Posts: 3 ua
vaio
Guest
|
Guest
Joined: Dec 2009
Posts: 3
ua
|
on bad English)When the GS appears normal and tech procedural animation? To be able to easily add a procedural aiming or shooting (up, down, left, right) and mix without problems running, walking, jumping ... etc. I think the potential of this technology for the GS is huge. A small example, the video: http://www.youtube.com/watch?v=l932bUpjfC8Can someone do this using the methods of animation GS? I think that there is no)) p.s. Here's what to 3Run
Last edited by vaio; 06/04/10 18:47.
|
|
|
Re: Easy animations
[Re: vaio]
#327128
06/04/10 18:49
06/04/10 18:49
|
Joined: Feb 2009
Posts: 3,207 Germany, Magdeburg
Rei_Ayanami
Expert
|
Expert
Joined: Feb 2009
Posts: 3,207
Germany, Magdeburg
|
So, I rewrote his animation script - i forgot something: you need to set blend_per to zero in the "normal" animation mode, and copy the actual animation into the string:
if(str_cmpi(anim_name, "walk") == 1) //if we already blended to the standing animation
{
ent_animate(ent, "walk", anim_per, ANM_CYCLE); //animate it in its "stand" animation
anim_per += 5 * time_step; //change 5 if you want
str_cpy(anim_name, "walk"); //change the actual animation to the stand animation
blend_per =0;
}
|
|
|
|