Raised This Month: $32 Target: $400
 8% 

Model Animation


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-15-2018 , 11:52   Model Animation
Reply With Quote #1

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.
__________________
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 08-15-2018 , 12:20   Re: Model Animation
Reply With Quote #2

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.
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-15-2018 , 13:59   Re: Model Animation
Reply With Quote #3

Quote:
Originally Posted by Ghosted View Post
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.
__________________

Last edited by edon1337; 08-15-2018 at 14:00.
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 08-15-2018 , 14:40   Re: Model Animation
Reply With Quote #4

Quote:
Originally Posted by edon1337 View 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.
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());
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM

Last edited by Ghosted; 08-15-2018 at 14:40.
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-15-2018 , 16:02   Re: Model Animation
Reply With Quote #5

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); 

__________________

Last edited by edon1337; 08-15-2018 at 16:04.
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 08-15-2018 , 16:22   Re: Model Animation
Reply With Quote #6

frames is not anim duration. frames must be divided by frames per second = duration.
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-15-2018 , 16:27   Re: Model Animation
Reply With Quote #7

Quote:
Originally Posted by Ghosted View Post
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); 

__________________
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 08-15-2018 , 16:31   Re: Model Animation
Reply With Quote #8

framerate should be 1.0 i think its multiplier of animation FPS
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 08-15-2018 , 16:38   Re: Model Animation
Reply With Quote #9

Quote:
Originally Posted by Ghosted View Post
framerate should be 1.0 i think its multiplier of animation FPS
Then EV_FL_animtime should be 4.8?
__________________

Last edited by edon1337; 08-15-2018 at 16:40.
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 08-15-2018 , 16:52   Re: Model Animation
Reply With Quote #10

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
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:53.


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