So, i'm trying to make a script for my server (for fun), i'm 100% bastard new with lua and gmod
What i'm trying to make: A third person view, from the right shoulder ( a little foward too)
I'm searching through the forum and found 2 scripts.
One clip through walls, and the other doesn't clipp but looks like laggy and i can't don't know how to move the camera to the right and up positions i wanted
so i merge some parts of the code and.. i can clip walls but can't move the camera
Here's my actual code:
if ( CLIENT ) then
local on = false
local function toggle()
on = !on
if on == true then
print( 'enabled' )
LocalPlayer():PrintMessage( HUD_PRINTTALK, "Third person mode enabled." )
else
print( 'disabled')
LocalPlayer():PrintMessage( HUD_PRINTTALK, "Third person mode disabled." )
end
end
hook.Add( "ShouldDrawLocalPlayer", "ThirdPersonDrawPlayer", function()
if on and LocalPlayer():Alive() then
return true
end
end )
hook.Add( "CalcView", "ThirdPersonView", function( ply, pos, angles, fov )
if on and ply:Alive() then
local view = {};
local dist = 80;
local trace = {};
trace.start = pos - ( angles:Right() * 20 ) + ( angles:Up() * 5 );
trace.endpos = pos - ( angles:Forward() * dist );
trace.filter = LocalPlayer();
local trace = util.TraceLine( trace );
if( trace.HitPos:Distance( pos ) < dist - 10 ) then
dist = trace.HitPos:Distance( pos ) - 10;
end;
view.origin = pos - ( angles:Forward() * dist );
view.angles = angles;
view.fov = fov;
return view;
end
end )
concommand.Add( "thirdperson_toggle", toggle )
end
That's how it looks:
https://i.imgur.com/JcvbVVp.jpg
That's how i want it to be:
https://i.imgur.com/KmIvrOQ.jpg
Yeah... this crosshair make's me crazzy too, but it's secondary now.
Sorry, you need to Log In to post a reply to this thread.