Snarkpit Articles


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.

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:



Post ReplyView Topic
Discussion
0 starsPosted by LickitySpliff on Sun Apr 17th 2005 at 1:44am

Hey <3 the tut
on the camera pointed at monitor part it looks like the camera is not dead center, and could that be why you only get 4?
gonna go try it..
0 starsPosted by shibby on Sun Mar 20th 2005 at 2:30am

Hmmm i dont know how relevant this is but i cant create a camera in CSS!? there doesnt seem to be a point_camera entity
ne help wud b great! thanx guys
0 starsPosted by greensinge on Mon Feb 21st 2005 at 10:20pm

Nice tut. I tried attaching the camera to a combine gunship and the effects were great. Thanks.
0 starsPosted by iceman on Wed Jan 26th 2005 at 11:34pm

About rof what did you set in your invalue parameter as?
0 starsPosted by JWNET on Thu Jan 13th 2005 at 8:18pm

Nice Tutorial! Saves me a lot of time trying to figure it out on my own. I'm going 2 make a huge security system with many cameras so this was a big help... Thx! smiley
0 starsPosted by Leck on Fri Dec 10th 2004 at 7:32pm

I'd like to get a moving camera working, using point_viewcontrol... it never wants to move for me. Nice tutorial though, helped a lot.
0 starsPosted by Rof on Fri Dec 10th 2004 at 6:04pm

I've managed cycling cameras using only one logic_case and one math_counter - you don't need a math_counter for each camera.
Set the "OutValue" of the counter to the logic_case's InValue.

For camera effects, you can use different textures, see over here: <a href="http://www.hl2world.com/wiki/index.php/Cameras" target="_blank">http://www.hl2world.com/wiki/index.php/Cameras</a>
You can also make your own effect by creating shader effects in a texture's .vmt file, it looks very flexible.
0 starsPosted by 7dk2h4md720ih on Fri Dec 10th 2004 at 2:10pm

0 starsPosted by Dred_furst on Thu Dec 9th 2004 at 3:18pm

What about camera effects? filters?

good tut tho :P
0 starsPosted by Paladin[NL] on Thu Dec 9th 2004 at 2:36pm

Last pic...damn, no &quot;hall-of-mirrors&quot; effect
Post ReplyView Topic