Player Animations - rebel1324/NutScript GitHub Wiki
Player Animations
NutScript allows various NPC models to be used as player models in addition to the normal player models. This is done by translating whatever player animation should be running to an equivalent NPC animation. For example, player models have the ACT_MP_STAND_IDLE
activity, but a citizen NPC model from Half-Life 2 does not. The equivalent activity is ACT_IDLE
. So, if your player model is set to a citizen NPC model, NutScript will translate the normal player animation to the equivalent citizen NPC one so the animations work as expected. In addition, NutScript also works with the weapon raise/lower system to allow for player models to have a raised/lower weapon animation for standing, walking, running, etc.
The code for supporting these extensions to normal player animations is in the nut.anim
library. The actual translations of animations happens here.
Model Classes
A model class is a collection of translations for player animations to animations for certain types of models. Here is the list of available model classes:
Model Class | Description |
---|---|
citizen_male |
A male NPC citizen model from Half-Life 2. |
citizen_female |
A female NPC citizen model from Half-Life 2. |
metrocop |
A metropolice NPC model from Half-Life 2. |
overwatch |
A Combine soldier NPC model from Half-Life 2. |
vort |
A vortigaunt NPC model from Half-Life 2. |
player |
A normal Garry's Mod player model. Player model paths normally start with models/player. |
zombie |
A zombie NPC model from Half-Life 2. |
fastZombie |
A fast zombie NPC model from Half-Life 2. |
Animation Setup
To make player animations work for models that are not normal player models (e.g. NPC models from HL2), one must set the appropriate model class for the model. To do this, you must call the following function shared:
nut.anim.setModelClass("models/your/model.mdl", "MODEL CLASS HERE")
The first argument is a string containing the path to your model. The second argument is a string containing one of the model classes listed above.
For example, in your schema's sh_schema.lua
file (or plugin's sh_plugin.lua
file), you would add:
nut.anim.setModelClass("models/dpfilms/metropolice/policetrench.mdl", "metrocop")
to make players with the "models/police.mdl" model use metropolice animations.
If you do not set up the appropriate model class for your player model, you may notice your player model T-posing.