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 :/
4,
1,
1,
Color( 120, 120, 255, 255 ) )
end
end
[/lua]
Screenshot:
[IMG]http://i.imgur.com/QeiGTW5.jpg[/IMG]
Forward is a unit vector; the directional vector of the angle.
You must multiply it by a length and add that to your origin.
[QUOTE=vexx21322;43806782]Forward is a unit vector; the directional vector of the angle.
You must multiply it by a length and add that to your origin.[/QUOTE]
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 [i]attach.Pos[/i] to [i]attach.Pos + ( attach.Ang:Forward() * 20 )[/i].
[url]http://wiki.garrysmod.com/page/render/DrawBeam[/url]
[QUOTE=Walrus Viking;43807048]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 [i]attach.Pos[/i] to [i]attach.Pos + ( attach.Ang:Forward() * 20 )[/i].
[url]http://wiki.garrysmod.com/page/render/DrawBeam[/url][/QUOTE]
Thanks it works :downs:
Sorry, you need to Log In to post a reply to this thread.