• render.DrawLine() - Positioning Help.
    5 replies, posted
Hello Facepunch. I've been having some difficulty with my entity i've been working on for the last 4 days now, I just can't seem to position the 'render.DrawLine()' correctly. What I'm trying to do it position the line as if it's like a lazer on a gun. I'm basically trying to position it straight to come outwards from the muzzle of the gun. -- Picture of turret. [URL="http://prntscr.com/ce90tv"]http://prntscr.com/ce90tv[/URL] [LUA] cam.Start3D2D(pos, ang, 0.7) render.DrawLine(self:GetGunBase():GetPos(), self:GetGunBase():GetAngles():Forward() * 100, Color(255,0,0,255), true ) cam.End3D2D() [/LUA] -- If someone can help me I'd really appreciate it, thank you.
-bump-
Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorld]Entity:LocalToWorld[/url] to easily tweak both positions as needed. [editline]5th September 2016[/editline] Why are you using Start3D2D? Don't. Just put your rendering code in the Draw hook.
Ok, I'll try that, thank you.
pretty sure you need to use cam.Start3D(), not Start3D2D EDIT: [CODE] cam.Start3D(); render.DrawLine(self:GetGunBase():GetPos(), self:GetGunBase():GetPos() + self:GetGunBase():GetAngles():Forward() * 100, Color(255,0,0,255), true ) cam.End3D(); [/CODE] if you're doing this in ENT:Draw you can remove the cam.Start3D/End3D
[QUOTE=NeatNit;51003396]Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Entity/LocalToWorld]Entity:LocalToWorld[/url] to easily tweak both positions as needed. [editline]5th September 2016[/editline] Why are you using Start3D2D? Don't. Just put your rendering code in the Draw hook.[/QUOTE] Thanks a bunch, it works! [editline]5th September 2016[/editline] [QUOTE=meirl;51005467]pretty sure you need to use cam.Start3D(), not Start3D2D EDIT: [CODE] cam.Start3D(); render.DrawLine(self:GetGunBase():GetPos(), self:GetGunBase():GetPos() + self:GetGunBase():GetAngles():Forward() * 100, Color(255,0,0,255), true ) cam.End3D(); [/CODE] if you're doing this in ENT:Draw you can remove the cam.Start3D/End3D[/QUOTE] Yeah, a silly mistake on my behalf, thanks.
Sorry, you need to Log In to post a reply to this thread.