I'm editing a thirdperson addon I found, and I was wondering how I could add the ability to rotate your camera around the player?
Here's all of the thirdperson code:
[CODE]
if ( CLIENT ) then
on = false
local function toggle()
on = !on
end
hook.Add( "ShouldDrawLocalPlayer", "ThirdPersonDrawPlayer", function()
if on and LocalPlayer():Alive() then
return true
end
end )
hook.Add( "CalcView", "ThirdPersonView", function( ply, pos, angles )
if ( !on || !IsValid( ply ) || !ply:Alive() || ply:InVehicle() || ply:GetViewEntity() != ply ) then return end
local view = {};
local dist = 100;
local trace = util.TraceHull( {
start = pos,
endpos = pos - (angles:Forward() * 65 + angles:Right() * -20),
filter = { ply:GetActiveWeapon(), ply },
mins = Vector( -4, -4, -4 ),
maxs = Vector( 4, 4, 4 ),
} )
if ( trace.Hit ) then
pos = trace.HitPos
else pos = pos - (angles:Forward() * 65 + angles:Right() * -20)
end
return {
origin = pos,
angles = angles,
drawviewer = true
}
end )
concommand.Add("zrp_cam_third", toggle)
end
hook.Add("PlayerBindPress", "ZRPTHIRDPERSON", function(ply, cmd, pressed)
if ( cmd == "gm_showhelp" && pressed ) then
RunConsoleCommand("zrp_cam_third")
elseif ( cmd == "gm_showhelp" && pressed ) then
RunConsoleCommand("zrp_cam_third")
end
end)
[/CODE]
bump
Would you be able to use thirdperson_mayamode 1? (or something similar)
You can add an angle to the calc view angles to rotate around. The angle could be calculated by however you want to do the camera rotation. If you want to do a click and drag get the distance from the click to the release
I'm not smart at all when it comes to LUA. Is there anything that I can use? I looked on the wiki and tried some stuff but no success...
Sorry, you need to Log In to post a reply to this thread.