Easiest way to draw a laser?

Hi,
I’ve been looking around and I can’t find anyway to draw a laser.
I want to draw a textured line (trails/laser) from a Player’s Head to where they are looking.
I’ve opened some examples such as Spiderman’s SWEP and it looks really advanced.
What is the easiest way to draw a line? I don’t want the line seen through walls and it can’t be animated.
I’m thinking it might be best serverside since I’m trying to make a laser shooting SWEP (from the head to where they are looking).
Anyone got any ideas?

Here’s an example I posted not long ago: http://forum.facepunch.com/showthread.php?t=1348923&p=44645896&viewfull=1#post44645896

Granted; it shows how to use the beams to create cubes, but there you go. They can’t be seen through the walls either.

PostDrawTranslucentRenderables

local MAP_ZONES_LASER = draw.GetMaterial( “cable/redlaser” );
local MAP_ZONES_POINTS = draw.GetMaterial( “cable/blue_elec” );
local MAP_ZONES_POINTS2 = draw.GetMaterial( “cable/hydra” );
local MAP_ZONES_POINTS3 = draw.GetMaterial( “cable/crystal_beam1” );

render.SetMaterial
render.DrawBeam

Thanks! But how do I make them so they can’t be seen through walls? I currently have this:


cam.Start3D(EyePos(),EyeAngles())
render.SetMaterial(Material("cable/redlaser"))
render.DrawBeam(v:GetBonePosition(v:LookupBone("ValveBiped.Bip01_Head1")),v:GetEyeTrace().HitPos,10,0,0,Color(255,0,0))
local tr = v:GetEyeTrace()
local pos1 = tr.HitPos + tr.HitNormal
local pos2 = tr.HitPos - tr.HitNormal
util.Decal("SmallScorch",pos1,pos2)
cam.End3D()

What hook do you use to draw the beams?

DrawHUD

No, that’s not correct hook to use. Use PostDrawTranslucentRenderables, without the cam.Start3D() stuff.

Okay. Is that clientside?

Obviously, all rendering hooks are clientside.