Create an animated model using Blender

Introduction

This tutorial covers the bare minimum parts required to create an animated model that could be imported into the Hammer Editor by creating the model and the animation in Blender.

Prerequisites

  • Basic knowledge of creating a static object in Blender 2.80 or above.
    • This tutorial uses Blender 4.2.
  • Basic concept of how animation works in Blender.
  • Understand how to create and import a static model from Blender to Hammer.

Creating the Object

First create the desired object with the UV mapping applied. The name of the object in Blender does not matter. Just ensure the image name referred in the material is already created in the Material Editor.

Static model creation in Blender

Vertex Groups

For each part of the object to perform an animation, a vertex group must be created, even though you want to move the entire object as one.

This can be easily done by entering Edit Mode. Then select the vertices (e.g. the body or one of the wheels) that you want to be in the group. Now click the green Data icon on the right hand side, a section for Vertex Groups should show.

Create a new vertex group and then click the Assign button to get the selected vertices assigned to that vertex group. The name of the vertex group is important (will explain why in the next few sections), and should contain only lowercase letters and underscore.

Vertex groups

Armature Creation

To prepare for animating vertex groups, an armature with bones will be required. For simplicity, only one armature with multiple bones is created in this tutorial.

Armature creation

Next, the armature needs to tie with the static object created by setting the armature as the parent of the object. To do this, first select the object, then select the armature (the selection order matters), then press Ctrl + P, a menu should show up for you to parent the object to the armature.

Armature parenting

If everything is done correctly, you should see the object as one of the children of the armature from the outliner on the right hand side.

Outliner

Bones Creation

Select the armature, switch to Pose Mode, you should see a single bone defined on the right hand side. To make the next steps simpler, delete the bone collection Bones that was created by default as part of the armature creation.

Bone collection

Now, switch back to Object Mode, then add a modifier as pictured below. This will allow multiple bones to be defined within the object.

Modifier 1

Modifier 2

With the armature selected, enter Edit Mode, then press Shift + A to create bones as needed.

One important thing is that the names of the bones created must match those of the vertex groups, as we are going to create animations to the bones themselves, and Blender (or even CS2) uses these names to determine which vertices to perform the animations.

The picture below shows how will the bones and vertex groups look like after the creations.

Bones and vertex groups

Animation

CS2 reads animations by "actions", and the game can usually play only one action at a time for an prop. Therefore, to define a new action in Blender, go to Dope Sheet in the bottom, and then create a new action. The action name should contain only lowercase letters and underscore.

Action creation

While this tutorial won't go too much into detail about how to create a certain type of animation in Blender, you will need to enter Pose Mode and then select the desired bone(s) to define various transformations at different keyframes.

The final duration of the action will be determined by the latest keyframe among all of the bones.

Animation

Export

Render Mesh

First, we want to export the mesh (with armature definition) used for rendering only. To do this, go to Object Mode, select both the object and the armature.

Rendering mesh selection

Then use the menu item to export the selected objects as an .fbx file. Please follow the settings as pictured below.

  • Selected Objects is checked.
  • Object Types are Armature and Mesh only.
  • Animation is unchecked.

Rendering mesh export

The file name should contain only lowercase English letters and underscore, please remember the file name used as this will be used in the next step.

Animation Definition

Next is to export the animation itself. To do this, select only the armature, and then use the menu item to start the export process.

Animation selection

Please follow the settings as pictured below.

The file name must be in the format {file name}@{action name}.fbx, where {file name} is the name used in the exported render mesh and {action name} is the name used when you create an action from the timeline. This will allow CS2 to read the animation correctly.

  • Selected Objects is checked.
  • Object Types is Armature only.
  • Animation is checked.

Animation export

Import

Open ModelDoc, create a new model, and then add the mesh as usual for a static prop. Ensure that the render mesh .fbx (not the animation file) file is selected.

Static model

To import the animation, add a new node, then select Add Simple Animations.... A file browser should pop up, then select the animation definition .fbx file exported in the last step.

Import animation

If the previous steps were taken correctly, you should be able to see the animation imported with a timeline that has the duration (i.e. number of frames) defined automatically. The only thing adjustable is the frame rate, which allows you to control the speed of the animation.

Animation timeline

To play the animation within the editor, simply click on the blue Play button at the bottom, the object should start the animation defined in Blender.

Animation preview

Don't forget to compile the model before using it in the Hammer Editor.

Using the Model

To use the model on your map, simply create a prop_dynamic entity, and then select the model you created in the previous step.

Then depending on the effect, you could either use a trigger to start the animation, or just have the entity started the animation right away as pictured below.

prop_dynamic

To preview the animation in the Hammer Editor, you could click on the Toggle model animation button on the toolbar.

Toggle model animation

Conclusion

That's it! This is the most time consuming tutorial I have even written as there were not many resources available online that tells people how to import an animated model from Blender into CS2 (or even any Source 2 games). Hope you found this tutorial helpful.