Animated Cameras in Garry’s Mod

All credit for this goes to MaxOfS2D who first documented this here. For people who don’t use Garry’s Mod regularly, this is a little more detailed tutorial on how to accomplish this.

Bringing the Map into 3DS Max
Exporting a map with Crafty will allow you to export models, textures, and brush geometry. Crafty is capable of opening numerous file formats, including .vmf and .bsp.

1) Open Crafty and select the game you will be using under Setup > Profiles.

2) Open the map file. This will allow you to fully preview the map.

3) Go to File > Export. Export the map as .obj file.
– Note: Exporting maps will also export the textures. These are numerous and will take up a lot of space.

4) Import the OBJ file into 3D Studio Max.
– Make sure the “Flip ZY-axis” option is unselected.

Creating the camera animation
1) In 3D Studio Max, go to Import > Merge and select the camera2.max file.
2) Create the camera animation.
– Using “Walk Through” mode will make this easier.

3) Select the static_prop bone. Use Export Selected to export the animation as an SMD file.
4) Create a QC file for the camera which includes the camera animations. Save and compile with GUIStudioMDL.
– The SMD and QC files used in this example can be downloaded here.
5) Open Faceposer and create a VCD file that includes the camera animation.

Playing the animation in Garry’s Mod
You will need these lua scripts installed first (extract to garrysmod\garrysmod\addons).
1) Spawn the camera.
– The camera should use the Kleiner NPC.
2) Set the name of the camera by typing in console: ent_setname camera
3) Use the teleport.lua script to set the world position of the camera.
– teleport_target camera – Sets the camera as the teleport target.
– teleport_yaw 270 – Fixes the rotation (this step may not be needed for every map).
– teleport_perform – Teleports the camera.
4) Use the imview.lua script.
– imview_select_name camera – Sets the camera as the target.
– imview_toggle – Toggles the camera view.
5) Play the VCD by using the following command “ent_fire camera setexpressionoverride scenes/flying_camera.vcd”, or by using the NPC Scene addon.

The Result

Problems and Fixes
1) Decompiling a TF2 map produces a different 0,0 coordinate compared to in game.
– Check the 3DS Max import settings to make sure the coordinates aren’t being altered.
2) The FOV in game is different compared to 3DS Max.
– Using the Better Camera addon will allow you to set the FOV in Garry’s Mod.

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.