Vehicle Third Person view?

I’ve been stuck on this thing for a while now.

How does garry calculate the vehicles third person camera’s origin position?

At first I thought it was an attachment, but it turned out its not. Its not in the vehicles center, neither its in the OBB center, but it has something to do with it, since the bigger the OBB is the higher the camera is. I’m recreating vehicles camera movement, that it wouldn’t be as static, but need for the camera to be at its original position.

Can someone please show the code (in C++) how garry did it?

It’s not C++ code, it’s in the base gamemode.
http://luabin.foszor.com/code/gamemodes/base/gamemode/cl_init.lua#395

Oh, I thought it was, thanks.

Did you only read the title of the thread or something? And **[Gamemode.CalcView

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Gamemode.CalcView)**is better anyway, since it works with hooks.

My old vehicle view:

[lua]hook.Add(“CalcView”, “jeep_view”, function ( _, pos, angles, fov )
if LocalPlayer():InVehicle() then
if GetConVarNumber( “gmod_vehicle_viewmode” ) == 1 then
local view = {}
view.origin = pos - ( angles:Forward() * ( 100 + ( LocalPlayer():GetVehicle():GetVelocity():Length() / 10 ) ) ) + ( LocalPlayer():GetVehicle():GetUp() * 80 )
view.angles = angles + Angle( 15, 0, 0 )
view.fov = fov
return view
end
end
end)[/lua]

Why are you sending FOV is you haven’t changed it? And it would easily fuck up whenever looked through a camera, sorry but its a sucky code, doesn’t even use a trace. For the camera fix just use this code:


if ValidEntity(ply:GetVehicle()) and GetViewEntity() == ply and ply:ShouldDrawLocalPlayer() and string.lower(ply:GetVehicle():GetClass()) != "prop_vehicle_prisoner_pod" then

Wouldn’t mess up addons such as WAC or VU mood too.

Anyway, already got my answer from this thread, now looking for some documentation on how GTA4 does it, I’d like to recreate that camera effect.