Garry's Mod

Garry's Mod

Not enough ratings
A Quick Explanation of Aimlayers
By Bump Attack ⊗
This guide gives a quick overview of how to set up looking animations in the .qc file for a playermodel. Good to know if your creating a playermodel that uses a custom skeleton and animations. This guide assumes that you already know how to make and export animations for source models in blender so I won't be covering that process in detail.
   
Award
Favorite
Favorited
Unfavorite
Creating Required Animations
In order to create an aimlayer you are going to need 9 poses for your playermodel:

LookUpRight
LookUp
LookUpLeft
LookRight
Reference
LookLeft
LookDownRight
LookDown
LookDownLeft

Each of these animations should be exported with one frame of animation.


For my playermodel I've only posed the neck and head, but your aim poses can effect as many bones as you want. This means you can make the entire body lean forwards or backwards when aiming up or down for example.
Creating a Weightlist
Once your animations have been created we can begin working with the .qc file.

The first thing your going to need to create is a weightlist. A weightlist is used to make an animation only affect specific bones in your model. Here is the weightlist used by my model:

Using the names of your model's bones from blender, any bone with a weight of 0 won't be affected by the animation, and any bone with a weight of 1 will be fully affected by the animation. If a bone has a weight of less than one, it will be partially affected by the animation, allowing multiple animations to blend together. Children inherit the weight of their parent bone if they are not included in the weightlist.

Here is the basic format for you to get started:

$weightlist "weights_layer_Look" { "Bone1" 0 "Bone2" 0 "Bone3" 0 }

Make sure that the bones that you posed are affected by the weightlist, and that any others aren't.
Adding Your Animations
Now that you have created a weighlist it is time to add your animations to the .qc and assign the weightlist to them. Here's what this looks like for my playermodel:


The line,
weightlist "weights_layer_Look"
refers to the name of the weightlist we created before and tells the animation which bones should be affected. If you make more weightlists for any reason make sure to give them each a unique name.

If the animations and weightlist you created use the same names as mine you can just copy the following to your .qc:

$animation "a_lookU" "anims\LookUp" { fps 24 weightlist "weights_layer_Look" } $animation "a_lookUR" "anims\LookUpRight" { fps 24 weightlist "weights_layer_Look" } $animation "a_lookUL" "anims\LookUpLeft" { fps 24 weightlist "weights_layer_Look" } $animation "a_lookR" "anims\LookRight" { fps 24 weightlist "weights_layer_Look" } $animation "a_lookL" "anims\LookLeft" { fps 24 weightlist "weights_layer_Look" } $animation "a_lookD" "anims\LookDown" { fps 24 weightlist "weights_layer_Look" } $animation "a_lookDR" "anims\LookDownRight" { fps 24 weightlist "weights_layer_Look" } $animation "a_lookDL" "anims\LookDownLeft" { fps 24 weightlist "weights_layer_Look" }
Creating a Blend Sequence
With all the animations added we can use them to make a blend sequence. This will tell the game to blend the animations together based on the angle you are looking in game:

$sequence "Look" { "a_LookUR" "a_LookU" "a_LookUL" "a_LookR" "anims\Reference" "a_LookL" "a_LookDR" "a_LookD" "a_LookDL" blendwidth 3 blend "aim_yaw" -66 66 blend "aim_pitch" -66 82 fps 24 loop hidden weightlist "weights_layer_Look" }

It is very important that the animations are added in the correct order as shown above.
Applying the Aimlayer
Finally, it is time to apply the aimlayer to your other sequences. You can do this by adding the line:
addlayer Look
to any sequence. Look is the name of the blend sequence we created in the previous step.

Here's an example of how this looks:


If a sequence doesn't include the addlayer line it won't use the aimlayer, so you need to add the line to each sequence that you want to use it.
Final Notes
Because the addlayer line lets you choose which sequences use your aimlayer, you can make multiple different aimlayers for your model and have different sequences use them. For example my model uses separate aimlayers for crouching and the prisoner pod:


If you want to make multiple aimlayers you can just follow the steps in this guide again, but use different names.

It is also possible to add multiple layers to the same sequence. This is useful if you make aimlayers for holding weapons and you want your sequences to use the same "Look" layer but different weapon aiming poses.

I hope this guide helps you on your way. I understand that even though this all makes sense to me, I might not have given enough details in every step, so feel free to ask me for clarification on anything.

Good luck!
12 Comments
Schizophrenia(2) 20 Feb @ 12:07pm 
Why animations broken on dedicated servers not local?
Ibai 8 Jun, 2024 @ 2:13pm 
What about corrective animations?
Kiryu type-3 5 May, 2024 @ 7:47am 
thanks pal! you are awesome!!!
Baby Wizard 15 Apr, 2024 @ 4:38pm 
Fuckin amazing, well done!
42 14 Apr, 2024 @ 4:18am 
You saved my time with that, thank you.
Anneke ⁧⁧[Aardwolf] 7 Mar, 2024 @ 2:37pm 
this guide is better than source SDK qc files, nice work
David Baszucki 29 Feb, 2024 @ 12:28am 
Say, did you have any concern from a steam workshop addon that applys a costum aimlayer animation to the rigs of the playermodels you have?
Biomod 29 Apr, 2023 @ 4:51am 
cringe
Shydun24 28 Jan, 2023 @ 1:10am 
you touched briefly on it, but how would i apply this to a custom holdtype using WOS?
DogeisCut 14 Oct, 2022 @ 12:30pm 
I dont know if this is a pac thing, but it seems my player model's head doesnt turn no matter what i do