The camera angle is an extremely simple thing to alter, and can complete a major step in many specialized mods. Here, you will learn just how to do that, so that anything from a funky FPS to a Grand Theft Auto 2 camera view can be used.
Posted by denreaper on Jun 13th, 2005
Basic Client Side Coding.
So you want to code your super great idea into a game, but you don't have any idea on where to start? Well one perfect place to start is with the camera views. By starting here, you can build a decent version for your modelers and mappers to see what their work will look like in-game. In this tutorial I'm going to use a standard real time strategy view as an example. You will need the standard tools used for coding in the Half-Life engine (MSVS.NET 2003 & the source sdk) and little to no knowledge of the Half-Life 2 engine to do this.
[page=Where do I start?]
You can start off by opening the client project. From there, open in_camera.cpp. This is where everything will be done, which includes some simple numbers that you can alter, and taking out the if statement that disables thirdperson being used in multiplayer mode. Starting at line 30, you will notice many lines that look similar to static ConVar cam_command( "cam_command", "0", FCVAR_CHEAT | FCVAR_ARCHIVE );. These are used to change the camera angle in any way imaginable.
[page=Editing the code]
Before we start digging into those static ConVar's, we are going to disable the if statement that tells the camera not to work in multiplayer mode. Do a search for CAM_ToThirdPerson, and then go a few lines down from there. You should now be around line 438. Find the code that says:
I would recommend testing to make sure it worked out before you move on.
[page=The camera done your way]
Now that the the camera is working in multiplayer, go back to line 30, and start altering your static ConVars. Experimentation seems to be the best method for this, but if you wanted to make yourself a descent real time strategy view, you would do something like this:
[page=Tying the knots]
Go ahead and compile. After starting up the game, you will have to type in "sv_cheats 1", and "thirdperson" into the console in order to make it work. Stay tuned for a tutorial continuation to solve this shortly. Also, look forward to a Warcraft 3 style zoom in using the scroll wheel. E-mail me at firstname.lastname@example.org for help, bugs, comments or suggestions.