Recently I’ve gotten into that part of Lua I’ve rarely been to - which is SWEPs.
After few days of playing with funcs, hooks and so on I got to the point where everything looks nice and works great… however, it lacks a proper ammo display - which I decided to use 3D2D Cam.
So here is my issue.
I am trying to position the rectangle so it appears right where the muzzleflash appears, I had no issues applying effect and it shows up at the correct position, but somehow the rectangle appears few inches to the back.
Is it caused by FOV not taken under consideration (no proper calculations were included) or do I have to do some calculations related to Cam3D2D’s draw scale?
Here is the image of what I mean (muzzleflash appears at the end of barrel, while the rectangle shows up way behind it):
function SWEP:PostDrawViewModel( vModel, person, weapon ) local pos = vModel:GetAttachment( 1 ).Pos local ang = self.Owner:EyeAngles() cam.Start3D2D( pos, Angle( ang.Pitch, ang.Yaw, ang.Roll ), 0.1 ) -- Angle( p, y, r ) instead of just ang so I can increase one of these if needed cam.IgnoreZ( true ) draw.RoundedBox( 0, 0, 0, 200, 250, Color( 255, 0, 0, 25 ) ) draw.SimpleTextOutlined( "AMMO", "DermaDefaultBold", 0, 0, Color( 255, 255, 255, 255 ), TEXT_ALIGN_LEFT, TEXT_ALIGN_TOP, 1, Color( 0, 0, 0, 255 ) ) cam.End3D2D() end
I rarely ask for help, so please, be nice, and thanks in advance!