Forward angle returns origin of map

Code i made that draws beam ends at origin of map and i dont know why.

Code:
[lua]
function SWEP:ViewModelDrawn()
local vm = self.Owner:GetViewModel()
if ( IsValid( vm ) ) then
local attach = vm:GetAttachment( vm:LookupAttachment( “muzzle” ) )
render.SetMaterial( Material( “effects/laser1” ) )
render.DrawBeam( attach.Pos + attach.Ang:Forward()*20 + attach.Ang:Up()*1.6,
attach.Ang:Forward(), – Origin of map for some reason :confused:
4,
1,
1,
Color( 120, 120, 255, 255 ) )
end
end
[/lua]
Screenshot:

Forward is a unit vector; the directional vector of the angle.

You must multiply it by a length and add that to your origin.

How? :v:

You’re using the second argument incorrectly. It’s not a direction parameter.

Think of the first parameter as PointA and the second PointB, in your case; you want to go from attach.Pos to attach.Pos + ( attach.Ang:Forward() * 20 ).

Thanks it works :downs: