This tutorial will show you how to create a television showing what's going on in another part of your map, and that is plugged into the wall- so that when you try to run off with it, it'll switch off.
So, first of all we will build the TV. Create a
prop_physics, name it
tv, and give it a suitable
model- for example,
props_c17/tv_monitor01.mdl. In the same space, make the glass front for realism- create a
prop_dynamic with the
props_c17/tv_monitor01_screen.mdl model, and set the
parent to
tv. Setting the parent field basically sticks objects together, so when you move the TV box the screen will go with it.
Create a
func_brush using the
toolsnodraw texture, and name it
tv_screen. Texture the viewing side with an appropriate monitor material- this might require you play around to find which is best, but we will use
tv_monitor1a here. Now fit the monitor texture to that face with the texture application tool, so that the image shown on the TV is the right size. Now move it into the TV, and place it slightly behind the screen. Set its
parent to
tv.
Finally, create another func_brush, but texture it with a black texture, and place it ever so slightly behind the other func_brush already inside your TV. This is because later on we will kill the screen in front showing the picture, so all we will see is a black screen. Also set the
parent to
tv.
Now we will setup the camera itself. Create a
point_camera entity, facing what you want it to film, and name it
tv_camera. Make sure the
start off flag isn't checked, and configure any other properties you want.
Create an
info_camera_link entity, named
tv_link. This entity will draw what the camera is recording on what we want it to. Set
entity Whose Material Uses _rt_camera to
tv_screen, and
camera name to
tv_camera.
Provided you used a suitable monitor texture earlier, you'll now have a working TV which you can throw around. If you want some kind of "news cast" or TV show, simply create a scene elsewhere in your map with the camera and relevant NPCs running around inside. Note how the TV screen will "draw off into infinity" (well, only 3 times) if you can see it in the camera!
And now for the rest of the setup. First of all, make a plug socket using whatever textures you can find (e.g.
decals/decalpoweroutlet001a) and turn it into a func_brush entity. Name it
plug. Next, create a
keyframe_rope entity behind the TV box where the wire will plug in, and name it
tv_plug. We don't really need this entity (though we could use an
info_target instead) but it stops the wire from looking like it's attached to the front of the TV when you start moving it around. Also set the
parent to
tv.
Now we will make the wire. Create a
move_rope entity, called
cable. Note that the wire that this entity makes starts at its origin, so place it inside or just in front of the plug socket. Set the
next keyframe to
tv_plug, which makes the wire trail between the socket and the back of the TV. Give it some
slack (e.g.
24) though the value will depend on your setup and you will have to play around with it. Set the
type to
rope, and make the
width 1.
At this stage, it might be worth compiling to check that your rope is setup correctly, as it can be a bit tricky to get working.
Finally, we need a
phys_lengthconstraint entity to "break" the wire when it's pulled too far. Set
entity 1 to
plug, and
entity 2 to
tv- these are the two points that this entity will judge the distance between (note that our TV itself is specified here instead of the tv_plug, as it won't work otherwise!). Set the
force limit to break to some small number, e.g.
50, and choose a nice spark sound for the
play on break property. Set the
additional length to the extra distance you have to pull the TV for it to break, e.g.
32 units.
Now we need the effects for when you break the cable. Click the "outputs" tab of your phys_lengthconstraint, and add a new output to break the cable:
OnBreak target
cable via
Break. Add another new output to turn off the TV screen:
OnBreak target
tv_screen via
Kill.
Finish off by placing your TV on a nice
prop_physics table, and compile!