m_PlayerAnimState

From Valve Developer Community
Revision as of 05:47, 19 May 2018 by Pinsplash (talk | contribs) (Usage)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

The m_PlayerAnimState object maintains a player's animation state. It is shared code.

There are two versions: CBasePlayerAnimState and CMultiPlayerAnimState.

Usage

Update( float eyeYaw, float eyePitch )
Manages ambient, looping animations (running/swimming, aiming, breathing) based on player velocity and look direction every frame.
Tip:CMultiPlayerAnimState will have your model playing one of the ACT_MP activities (search in Visual Studio's Class View for a list). You will probably want to add activity translation tables to your weapons to turn these into activities pertaining to the weapon currently being held. Missing or incomplete translation tables are the number one cause of unanimated models.
Note:Your player model must be set up with the appropriate blend sequences for this to work. Unfortunately there are several different schemes floating around: Ep1, OB and Counter-Strike players are all driven differently. Check SetupPoseParameters() to see what your AnimState object is looking for.
DoAnimationEvent( PlayerAnimEvent_t event, int nData = 0 )
Begins a discrete, event-based animation (crouching, shooting, reloading) whenever called. PlayerAnimEvent_t is an enum value that defines what type of animation event this is; it is translated into an activity elsewhere depending on the status of the player (weapon held, swimming, etc).

Implementation

Implementation is complex, and requires editing several classes. See SDK Skeleton's multiplayer components for a finished product.

Dispatching to clients

In multiplayer you must dispatch animation events to all onlooking clients, a job which is not performed by CBasePlayer. See m_PlayerAnimState/TempEnt for the temporary entity used by Valve.