WiseLaser
This tutorial was originally created by wisemx. It was originally posted on SDKnuts.net.
In this tutorial, we will approach basic aspects of using lasers in level design.
Moving Laser
The image to the right shows a laser that travels back and forth from both ends of a tunnel, and will kill the player if touched. The height of the tunnel is big enough for the player to be able to jump over the laser. The player can not go under the laser at this height however.
There are several ways to create an effect like this, the settings and methods that is used in this tutorial can easily be changed to your liking. Notice the sprite placed on each side for a burning hot effect.
There's a secondary ambient effect used in this tutorial, not related to the laser: a water puddle was created on the floor, and it will make a splash sound.
An env_beam
is used on each side of the tunnel to create the moving laser:
Class: env_beam | ||
Keyvalues | Comments | |
Parent | Beam01train | Right side parent equals Beam02train |
Brightness | 75 | |
Beam Color | 255 0 0 | |
Life | 0 | (Infinite) |
Width of Beam | 0.7 | |
Noise | 0 | |
Sprite name | sprites/laserbeam.spr | |
Texture scroll rate | 40 | |
Damage | 1000 | |
Start Entity | Beam01 | Beam02 for the right side |
Ending Entity | Beam02 | Beam01 for the right side |
Touch Type | Not a tripwire | |
Flag | ||||
Start | ||||
Setup in Hammer
To the right there's a shot from Hammer of the left side env_sprite, env_beam
, func_tracktrain and first path_track.
Objects used
- Transparent =
func_tracktrain
- Purple =
env_beam
- Green =
env_sprite
- Red =
path_track
By looking at the image you can see the env_sprite
is parented to the env_beam
.
The env_beam
is parented to the invisible func_tracktrain
.
Our first path_track
, the starting point, is nestled right in there with the other entities.
env_sprite
These are the settings for each env_sprite
, which are only used for a slight effect.
Class: env_sprite | ||
Keyvalues | Comments | |
Parent | Beam01 | Beam02 for right side |
Render FX | Normal | |
Render Mode | Additive | |
FX Amount | 150 | |
FX Color | 255 0 0 | |
Disable receiving shadows | Yes | |
Frame rate | 10.0 | |
Sprite name | materials/sprites/glow03.vmt | |
Scale | 0.2 | |
Size of Glow | 2.0 | |
Flag | ||||
Start | ||||
func_tracktrain
Settings for each func_tracktrain
:
Class: func_tracktrain | ||
Keyvalues | Comments | |
Name | Beam01train | Beam02train for the right side |
Disable receiving shadows | Yes | |
Disable Shadows | Yes | |
First Stop Target | Beam01path01 | Beam02path01 for the right side |
Max speed | 60 | |
Initial Speed | 60 | |
Change Velocity | Instantaneously | |
Change Angles | Near path_tracks | |
Distance between the wheels | 10 | |
Height above the track | 0 | |
Bank angle on turns | 0 | |
Move sound | d3_citadel.weapon_zapper_beam_loop1 | Left side only |
Volume | 2 | |
Flag | ||||
No User Control | ||||
Passable | ||||
Fixed Orientation | ||||
Is unblockable by Player | ||||
path_track
Notice, in the image to the right, that there are only 4 path_track
entities: two on each side, for each func_tracktrain
.
On the left side the first path_track
references the second path_track
which in turn references the first path_track
, which causes the lasers on each side to go in a loop, back and forth.
By adding more of these path_track
's you could cause the laser to travel in a zigzag pattern. You could also attach multiple lasers to each side, for a double effect as an example. You are free to change the visual effect of the laser, its speed and the tiny sprite to your liking.
env_beam
was used on each side rather than only on one side is that the laser effect appears to be much better. However, you can experiment with this.Settings for first path_track
on the left side:
Class: path_track | ||
Keyvalues | Comments | |
Name | Beam01path01 | Beam02path01 on the Right side |
Name | Beam01path02 | Beam02path02 on the Right side |
Water puddle
The water puddle effect is done with an info_overlay. One can place an env_cubemap over this, an ambient_generic for the sound and a trigger_multiple to play the sound when the player steps there.
Setup in Hammer
info_overlay
Class: info_overlay | ||
Keyvalues | Comments | |
Material | decals/decalborealispuddle001a | |
ambient_generic
Class: ambient_generic | ||
Keyvalues | Comments | |
Name | WaterSound | |
Sound name | Water.StepLeft | |
Volume | 4 | |
Flag | ||||
Start Silent | ||||
Is NOT Looped | ||||
trigger_multiple
Class: trigger_multiple | ||
Keyvalues | Comments | |
Start disabled | No | |
Delay before reset | 1 | |
Flag | ||||
Clients | ||||
Everything | ||||
My output | Target entity | Target input | Parameter | Delay | Only once | Comments | ||
OnStartTouch | WaterSound | PlaySound | ||||||
Laser turning a corner
The trick to making the laser turn a corner is to stop the inside train until the outside train catches up.
Take a look at the Outputs for the path_tracks
in the corner, should be straight-forward.
The next step is to make the laser teleport to the first path_track
so it can start over.
To do that just check the flag Teleport to this path_track
, in both of the first ones.
The download for this tutorial contains two vmf projects. In the second example the laser turns a corner and travels down another tunnel. Notice that no sprites were used in the second example, since it looked better without them.