# Creating a ThirdPerson View

I’ve got my view offset, but the point that the player is looking at isn’t the point the view is looking at.

i.e.

As you can see, the view angle and the player eye angles although the same are looking at different points, as they’re parallel. How can I get the angle of the view to face the point the players eyes are looking at?

Would anyone mind explaining the math?

Cheers

Should be as simple as setting some view angles, no?

Just throwing the idea out there, I don’t have experience with this.

[lua]
function GM:CalcView(ply, pos, angles, fov)
local view = {}
view.origin = pos - (angles + Angle(0, 20, 0)):Forward() * 80
view.angles = angles
view.fov = 80

``````return view
``````

end
[/lua]

Doesn’t the actual point the player is looking at change with range though? Won’t I have to account for that?

[editline]13th June 2013[/editline]

Similar to what I have at the moment

``````

function GM:CalcView(ply, pos, angles, fov)
if thirdperson then
local view = {}
view.origin = pos - (angles:Forward()*100)+(angles:Right()*20)
view.angles = angles
view.fov = fov
return view
else
return
end
end

``````

But still, the point the player is looking at changes with range, so wouldn’t your code not account for that.