Advanced Camera Techniques
by Joe-Bob (view all articles)

unrated
Cycling between cameras, chase cameras, etc.
by Joe-Bob (view all articles)

unrated

Advanced Camera Techniques
This tutorial goes over some of the frequent questions people ask about cameras. It assumes a basic knowledge of cameras in Half-Life 2.
As powerful as the Source engine is, it simply will not display multiple camera views at the same time. If you try to link different camera to different monitors, you'll find yourself with all the monitors displaying a single camera angle. Now, in the single-player game you can cycle through several security camera views.
First, create a simple map if needed. Add your monitors using the appropriate texture, setting their name to whatever you find appropriate. Create your point_camera entities, and finally make some info_camera_link entities to attach your cameras to the monitor brushes. Oddly, it seems that only one of the info_camera_link entities needs its Entity Whose Material Uses _rt_ca... to be attached to a monitor for the rest of them to function. To be safe, I would attach them to as many of the monitors as you can, but you can take advantage of this to have different name values for the monitors.
Ok, now on to some new stuff! First, go to the flags tab of your point_camera entities, and set them all to "Start Off". One camera will start the rotation, however, and its "Start Off" flag can be unchecked if you want.
It's about it get entity heavy. For the purposes of this tutorial, I will only cycle between three cameras. You can easily create more, don't worry.
I'm guessing you already added cameras, but for simplicity's sake, their Names are camera1, camera2, and camera3.Create a logic_case entity:
Name : camera_case
Case 01 : 1
Case 02 : 2
Case 03 : 3
Your logic_case entity will receive a numeric value, and trigger the right output depending on the number. Go to the Outputs tab and insert the following values:
SetOnAndTurnOthersOff will do just as it says, and it's the safest way to switch a camera view.
Create a func_button brush entity. It triggers 3 entities used to cycle between camera views.
Now, set the output as follows:
Here's the hard part. Using three math_counter entities (one for each camera), we will loop between 0 and 3. Whenever a counter reaches three, it resets to zero and tells logic_case to turn a particular camera on. Don't get it? Fine, just follow along. You'll understand.
Three math_counter entities:
Name : camera_cycler1
Initial Value : 0
Minimum Legal Value : 0
Maximum Legal Value : 3 (number of cameras)
Name : camera_cycler2
Initial Value : 2
Minimum Legal Value : 0
Maximum Legal Value : 3
Name : camera_cycler3
Initial Value : 1
Minimum Legal Value : 0
Maximum Legal Value : 3
Now, set their output flags to this:
As you can see, whenever a math_counter reaches its maximum, it resets itself to zero and targets the logic_case with a camera number.
Here's a table to show exactly what happens to the math_counter entities whenever the button is pressed:
Since camera_cycler1 is initially 0, its camera is not set. It should be set to be on (in its flags) already.
You're done! Congratulations!
(Disclaimer: If there's an easier way to do this, please comment on it. I'd be more than happy to change it.)
Chase Cameras:
In a point_camera entity, you can set its Parent Value to the name of any entity, even an NPC or vehicle! If you do that, make sure that the camera's view isn't obstructed by the model. View it in action:
Cameras pointed at monitors
This is a fairly important detail. If you point a camera at a monitor, the game will not lock up or experience any major slowdown. Despite what you would think, the view is only repeated a couple times.
Evidence:

This tutorial goes over some of the frequent questions people ask about cameras. It assumes a basic knowledge of cameras in Half-Life 2.
Cycling through cameras
As powerful as the Source engine is, it simply will not display multiple camera views at the same time. If you try to link different camera to different monitors, you'll find yourself with all the monitors displaying a single camera angle. Now, in the single-player game you can cycle through several security camera views.
First, create a simple map if needed. Add your monitors using the appropriate texture, setting their name to whatever you find appropriate. Create your point_camera entities, and finally make some info_camera_link entities to attach your cameras to the monitor brushes. Oddly, it seems that only one of the info_camera_link entities needs its Entity Whose Material Uses _rt_ca... to be attached to a monitor for the rest of them to function. To be safe, I would attach them to as many of the monitors as you can, but you can take advantage of this to have different name values for the monitors.
Ok, now on to some new stuff! First, go to the flags tab of your point_camera entities, and set them all to "Start Off". One camera will start the rotation, however, and its "Start Off" flag can be unchecked if you want.
It's about it get entity heavy. For the purposes of this tutorial, I will only cycle between three cameras. You can easily create more, don't worry.
I'm guessing you already added cameras, but for simplicity's sake, their Names are camera1, camera2, and camera3.Create a logic_case entity:
Name : camera_case
Case 01 : 1
Case 02 : 2
Case 03 : 3
Your logic_case entity will receive a numeric value, and trigger the right output depending on the number. Go to the Outputs tab and insert the following values:

SetOnAndTurnOthersOff will do just as it says, and it's the safest way to switch a camera view.
Create a func_button brush entity. It triggers 3 entities used to cycle between camera views.
Now, set the output as follows:

Here's the hard part. Using three math_counter entities (one for each camera), we will loop between 0 and 3. Whenever a counter reaches three, it resets to zero and tells logic_case to turn a particular camera on. Don't get it? Fine, just follow along. You'll understand.
Three math_counter entities:
Name : camera_cycler1
Initial Value : 0
Minimum Legal Value : 0
Maximum Legal Value : 3 (number of cameras)
Name : camera_cycler2
Initial Value : 2
Minimum Legal Value : 0
Maximum Legal Value : 3
Name : camera_cycler3
Initial Value : 1
Minimum Legal Value : 0
Maximum Legal Value : 3
Now, set their output flags to this:

As you can see, whenever a math_counter reaches its maximum, it resets itself to zero and targets the logic_case with a camera number.
Here's a table to show exactly what happens to the math_counter entities whenever the button is pressed:

Since camera_cycler1 is initially 0, its camera is not set. It should be set to be on (in its flags) already.
You're done! Congratulations!
(Disclaimer: If there's an easier way to do this, please comment on it. I'd be more than happy to change it.)
Extra Camera Information
Chase Cameras:
In a point_camera entity, you can set its Parent Value to the name of any entity, even an NPC or vehicle! If you do that, make sure that the camera's view isn't obstructed by the model. View it in action:


Cameras pointed at monitors
This is a fairly important detail. If you point a camera at a monitor, the game will not lock up or experience any major slowdown. Despite what you would think, the view is only repeated a couple times.
Evidence:
