Creating custom animations
The Perfect Hands animation works by changing the angles of the players' bones.
To create a custom animations, you will need to know exact angles of the bones and bone names.
Example of the animation definition:
P.animations.Add("surrender", {
["ValveBiped.Bip01_L_Forearm"] = Angle(25, -65, 25),
["ValveBiped.Bip01_R_Forearm"] = Angle(-25, -65, -25),
["ValveBiped.Bip01_L_UpperArm"] = Angle(-70, -180, 70),
["ValveBiped.Bip01_R_UpperArm"] = Angle(70, -180, -70)
})
Explanation:
- Where surrender — this is animation ID, this value should be unique across all animations, since it is used to identify what bones to move.
- Where ValveBiped.Bip01_L_Forearm/ValveBiped.Bip01_R_Forearm/ValveBiped.Bip01_L_UpperArm/etc. — this is bone names, basically a unique bone ID. List of all default bones can be found here.
- Where Angle(25, -65, 25)/Angle(-25, -65, -25)/Angle(-70, -180, 70)/etc. — this is desired angle that should be applied to a bone. More about angle structure.
All default animations can be found in lua/mvp/packages/perfecthands/sh_animations_list.lua file.
To create your custom animation, you'll need to place animation definition in the lua/mvp/packages/perfecthands/sh_animations_list.lua file, following the example above.
As you can see, in the above examples there is no explicit mention of the animation name or description. This is because all language-dependent parameters are handled by the language system. To define name and description, navigate to lua/mvp/packages/perfecthands/languages/[your language].lua file. There are a number of strings, we're looking for the block of strings that contain phands.animation as its prefixes.
Example of the animation name and description in language system:
l["phands.animation.surrender"] = "Surrender"
l["phands.animation.surrender.description"] = "You raise your hands and accept your fate."
Explanation:
- Where phands.animation.surrender — a language key, tied to a specific animation, representing name of said animation.
- Where phands.animation.surrender.description — a language key, tied to a specific animation, representing description of said animation.
Keys are formed following this format:
For the name: phands.animation.[animation id]
For the description: phands.animation.[animation id].description
- phands.animation. — always a static part.
- [animation id] — your unique animation ID.
To add a name and a description to your custom animation, you'll need to place language definitions in the lua/mvp/packages/perfecthands/languages/[your language].lua file, following the example above.