AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Model Animation (https://forums.alliedmods.net/showthread.php?t=310004)

edon1337 08-15-2018 11:52

Model Animation
 
How do I properly set a model animation? Let's say my model has these sequences:

- dummy
- death
- idle

1. How do I make 'idle' as the default state? Right now it is in dummy as default because it's the first one in list, and to make it stay like that.

2. How do I play the 'death' animation when the player dies?

I tried using PreThink but there was 2 flaws:
- Because the animation was updated a lot of times in a single frame, it was weird
- When player died, and then later spawned, the animation was being changed on the other model too.

Ghosted 08-15-2018 12:20

Re: Model Animation
 
Code:

stock Util_PlayAnimation(index, sequence, Float: framerate = 1.0)
{
    entity_set_float(index, EV_FL_animtime, get_gametime());
    entity_set_float(index, EV_FL_framerate,  framerate);
    entity_set_float(index, EV_FL_frame, 0.0);
    entity_set_int(index, EV_INT_sequence, sequence);
}

Code from this post.

edon1337 08-15-2018 13:59

Re: Model Animation
 
Quote:

Originally Posted by Ghosted (Post 2610323)
Code:

stock Util_PlayAnimation(index, sequence, Float: framerate = 1.0)
{
    entity_set_float(index, EV_FL_animtime, get_gametime());
    entity_set_float(index, EV_FL_framerate,  framerate);
    entity_set_float(index, EV_FL_frame, 0.0);
    entity_set_int(index, EV_INT_sequence, sequence);
}

Code from this post.

I already know that stock but what I'm unsure of is properly making an animation stay forever, as described in the first post.

Ghosted 08-15-2018 14:40

Re: Model Animation
 
Quote:

Originally Posted by edon1337 (Post 2610342)
I already know that stock but what I'm unsure of is properly making an animation stay forever, as described in the first post.

Then you should update animation by task, which requires current animation duration. For update use
Code:

entity_set_float(index, EV_FL_animtime, get_gametime());

edon1337 08-15-2018 16:02

Re: Model Animation
 
I checked with Jed's Half Life Viewer and idle animation has 141 frames, does that mean I have to use 141.0 as the framerate?

So, something like this?
PHP Code:

public MakeAnimid )
{
    
set_task1.0"@RenewAnimation"id, .flags="b" );
}

@
RenewAnimationid )
{
    
Util_PlayAnimationididle141.0 );
}

stock Util_PlayAnimation(indexsequenceFloatframerate 1.0

    
entity_set_float(indexEV_FL_animtimeget_gametime()); 
    
entity_set_float(indexEV_FL_framerate,  framerate); 
    
entity_set_float(indexEV_FL_frame0.0); 
    
entity_set_int(indexEV_INT_sequencesequence); 



Ghosted 08-15-2018 16:22

Re: Model Animation
 
frames is not anim duration. frames must be divided by frames per second = duration.

edon1337 08-15-2018 16:27

Re: Model Animation
 
Quote:

Originally Posted by Ghosted (Post 2610374)
frames is not anim duration. frames must be divided by frames per second = duration.

Ah, thanks for the information.

So basically there's 141 Frames and FPS is 30 = 4.7.

So is this correct?
PHP Code:

public MakeAnimid )
{
    
set_task4.7"@RenewAnimation"id, .flags="b" );
}

@
RenewAnimationid )
{
    
Util_PlayAnimationididle4.8 );
}

stock Util_PlayAnimation(indexsequenceFloatframerate 1.0

    
entity_set_float(indexEV_FL_animtimeget_gametime()); 
    
entity_set_float(indexEV_FL_framerate,  framerate); 
    
entity_set_float(indexEV_FL_frame0.0); 
    
entity_set_int(indexEV_INT_sequencesequence); 



Ghosted 08-15-2018 16:31

Re: Model Animation
 
framerate should be 1.0 i think its multiplier of animation FPS

edon1337 08-15-2018 16:38

Re: Model Animation
 
Quote:

Originally Posted by Ghosted (Post 2610379)
framerate should be 1.0 i think its multiplier of animation FPS

Then EV_FL_animtime should be 4.8?

Ghosted 08-15-2018 16:52

Re: Model Animation
 
animtime is when animation started. at set_task you dont need to reSet sequence id, only animtime would be enough. for so in task call you should only use animtime = gametime


All times are GMT -4. The time now is 12:47.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.