Facepunch has some free to use viewmodels available in the cloud browser. They’re separated into a weapon model and a hands/arms model.

Create a new prefab for your viewmodel - this is my preferred way to set up viewmodels, as you can easily tweak and test them in the editor before using them in code, adjusting fingers, positions, etc.

Tip: You could have either a Weapon GameResource and put the prefab there to clone it in when equipping, or have a virtual property on the weapon component that spawns the prefab when the weapon is equipped.

You can start by adding a SkinnedModelRenderer to your viewmodel prefab, and then assigning the weapon model to it. Make sure it’s a viewmodel and not a world model, as the latter has no animations.

SkinnedModelRenderer Weapon

Next, you’ll want to add another SkinnedModelRenderer for the hands/arms model. This one can be a separate GameObject next to the weapon GameObject. For this one, you want the facepunch.v_first_person_arms_human model.

SkinnedModelRenderer Arms

On the SkinnedModelRenderer for the arms, make sure to set the Bone Merge Target to the weapon’s SkinnedModelRenderer. This will ensure that the arms animate correctly with the weapon.

Do NOT bone merge the weapon to the arms - it has to be the other way around. Arms to weapon.

Bone Merge Target

Spawning this prefab as a child of the camera will give you a basic viewmodel setup.

I originally tried to update the viewmodel position in OnUpdate, but this caused jittering. I’m pretty sure this is because the camera position is updated after OnUpdate, so parenting the viewmodel to the camera and resetting its local position works better.

Accessing the SkinnedModelRenderer weapon component in code allows you to play animations on it. You use the Set method with the name of the animation you want to play. How you want to access the weapon and hands renderers is up to you - you could have a ViewModel component that holds references to them like I have.

public class ViewModelComponent : Component
{
    [Property] public SkinnedModelRenderer Weapon { get; set; }
    [Property] public SkinnedModelRenderer Arms { get; set; }
}
ViewModelGameObject.GetComponent<ViewModelComponent>().Weapon.Set("b_attack", true);

The official docs page on viewmodels has more information from here on, like the available parameters. You can also find all the parameters if you open the Parameters group on the SkinnedModelRenderer component in the editor.

Parameters Group