|
how to use ent_blend?
#242175
12/21/08 19:05
12/21/08 19:05
|
Joined: Sep 2008
Posts: 69
upsidedownman
OP
Junior Member
|
OP
Junior Member
Joined: Sep 2008
Posts: 69
|
Hi, i am trying to make my players animation look better so i tried using ent_blend but how do you use it? I read the manual description of it but it really doesn't help. here is what i want to use it for,
if(key_w)
{
ent_animate(player, "run", run_speed, ANM_CYCLE);
}
if(key_s)
{
ent_animate(player, "walk_back", walk_speed, ANM_CYCLE);
}
if(key_w == NULL && key_s == NULL)
{
run_speed = 0; walk_speed = 0;
ent_animate(player, "stand", stand_speed, ANM_CYCLE);
}
i want it to go smoothly from stand to run and vice versa. But how would i use ent_blend to do this? Thanks ahead of time.
|
|
|
Re: how to use ent_blend?
[Re: upsidedownman]
#242184
12/21/08 19:46
12/21/08 19:46
|
Joined: Nov 2007
Posts: 1,032 Croatia
croman
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,032
Croatia
|
it's quite difficult to do that. i'm using this David Lancaste's code from KH Movement tutorial: animate.c
//*******************************************************
// -- DEFINES --
//*******************************************************
#define animate skill31
#define animate2 skill32
#define animblend skill33
#define currentframe skill34
#define blendframe skill35
#define nullframe -2
#define blend -1
#define stand 0
#define run 1
#define walk 2
#define jump 3
#define fall 4
#define crouch 5
#define stand_aim 6
// Movement speed constants
#define run_speed 18
#define strafe_speed 12
#define run_animation_speed 16
//*******************************************************
// -- HANDLE ANIMATION -- function
//*******************************************************
function handle_animation(animation_speed)
{
while(1){
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,"stand",my.animate,ANM_CYCLE);
if (my.currentframe == run) ent_animate(my,"run",my.animate,ANM_CYCLE);
if (my.currentframe == walk) ent_animate(my,"walk",my.animate,ANM_CYCLE);
if (my.currentframe == crouch) ent_animate(my,"crouchaim",my.animate,ANM_CYCLE);
if (my.currentframe == stand_aim) ent_animate(my,"standaim",my.animate,ANM_CYCLE);
if (my.blendframe == stand) ent_blend("stand",0,my.animate2);
if (my.blendframe == run) ent_blend("run",0,my.animate2);
if (my.blendframe == walk) ent_blend("walk",0,my.animate2);
if (my.blendframe == crouch) ent_blend("crouchaim",0,my.animate2);
if (my.blendframe == stand_aim) ent_blend("standaim",0,my.animate2);
my.animate2 += 45 * time_step;
if (my.animate2 >= 100)
{
my.animate = 0;
my.animblend = my.blendframe;
my.blendframe = nullframe;
}
}
if (my.animblend == stand)
{
ent_animate(my,"stand",my.animate,ANM_CYCLE);
my.animate += 1 * animation_speed * time_step;
my.animate %= 100;
my.currentframe = stand;
}
if (my.animblend == run)
{
ent_animate(my,"run",my.animate,ANM_CYCLE);
my.animate += 7 * animation_speed * time_step;
my.animate %= 100;
my.currentframe = run;
}
if (my.animblend == walk)
{
ent_animate(my,"walk",my.animate,ANM_CYCLE);
my.animate += 7 * animation_speed * time_step;
my.animate %= 100;
my.currentframe = walk;
}
if (my.animblend == crouch)
{
ent_animate(my,"crouchaim",my.animate,ANM_CYCLE);
my.animate += 7 * animation_speed * time_step;
my.animate %= 100;
my.currentframe = crouch;
}
if (my.animblend == stand_aim)
{
ent_animate(my,"standaim",my.animate,ANM_CYCLE);
my.animate += 7 * animation_speed * time_step;
my.animate %= 100;
my.currentframe = stand_aim;
}
wait(1);
}
}
and then put a call handle_animation(1); in a while loop in player function or main function. and then use it like this in player function loop:
if (key_w || key_s && key_c)
{
if (my.animblend == stand)
{
if (key_shift == 1) { my.blendframe = run; } else { my.blendframe = walk; }
}
if (my.animblend == walk && key_shift == 1) { my.blendframe = run; }
if (my.animblend == run && key_shift == 0) { my.blendframe = walk; }
}
if (!key_w && !key_s && !key_c)
{
if (my.animblend > stand)
{
my.blendframe = stand;
}
}
if(key_c)
{
if(my.animblend != crouch)
{
my.blendframe = crouch;
}
}
Ubi bene, ibi Patria.
|
|
|
Re: how to use ent_blend?
[Re: upsidedownman]
#242188
12/21/08 19:55
12/21/08 19:55
|
Joined: Nov 2007
Posts: 1,032 Croatia
croman
Serious User
|
Serious User
Joined: Nov 2007
Posts: 1,032
Croatia
|
it will work really nice. i'm using it for quite a long time and still i'm having troubles understanding that blending perfectly lol
Ubi bene, ibi Patria.
|
|
|
Re: how to use ent_blend?
[Re: croman]
#242194
12/21/08 20:11
12/21/08 20:11
|
Joined: Aug 2008
Posts: 218 U.S.
GamerX
Member
|
Member
Joined: Aug 2008
Posts: 218
U.S.
|
I agree ent_blend is tricky at times your best bet would be to use that script try to add on to it until you get it right then just keep improving it until you know how to use it correctly.
"You may never know what results come of your action, but if you do nothing there will be no result." -Mahatma Gandhi
|
|
|
Moderated by mk_1, Perro, rayp, Realspawn, Rei_Ayanami, rvL_eXile, Spirit, Superku, Tobias, TSG_Torsten, VeT
|