• CalcView Issues.
    3 replies, posted
Hey all, I've been away from gmod for quite some time now, and I've just recently decided to get back into scripting. In all honesty, I'm pretty terrible with vector math, angles, and all that jazz, but I tried putting together a basic 'over the shoulder' system. Right now I have: [code] hook.Add( "CalcView", "ThirdPersonView", function( ply, origin, ang, fov ) if ply:Alive() then local eyepos = ply:EyePos() local plyang = ply:GetAimVector() local tracedata = {} tracedata.start = eyepos tracedata.endpos = eyepos + ply:GetForward() * -40 tracedata.endpos = tracedata.endpos + plyang:Angle():Right() * 25 tracedata.filter = ply tracedata.mask = MASK_SOLID_BRUSHONLY local trace = util.TraceLine(tracedata) local pos = trace.HitPos:ToScreen() local view = {} view.origin = trace.HitPos + ply:GetForward() * 5 view.angles = ply:EyeAngles() + Vector(0,2,0) view.fov = fov return GAMEMODE:CalcView( ply, view.origin, view.angles, view.fov ) end end )[/code]I found this in an old post on FP using google, and edited it a bit. At a distance, it works well, [img_thumb]http://www.decrepitgaming.com/images/wtf1.png[/img_thumb] However, when you get closer to the player entity, it goes way off from the crosshairs: [img_thumb]http://www.decrepitgaming.com/images/wtf2.png[/img_thumb] I also thought of just using the trace from the gun to make some sort of 'laser' to show players where they're aimed, but I also have no idea how to go about doing that. Any help is greatly appreciated! It's good to be back ;D
For the laser you can use [b][url=http://wiki.garrysmod.com/?title=Render.DrawBeam]Render.DrawBeam [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b].
Ah, very nice :D I'd like crosshairs over the laser, but if I can't get help with that, lasers it is! hehe
(view.origin - eyepos):Angle() you might have to swap them, cause i always forget which direction it is
Sorry, you need to Log In to post a reply to this thread.