Making the player look towards cameras hitpos?

Im trying to figure out how to make the player aim towards the middle of the screen when in shoulder mode thirdperson but no matter what I use to set the angles it seems like it locks the players view to a corner of the map. Any idea how to get this to work?

Here is a pic to explain how it is and how I want it.

Also sorry for making like 3 threads in a day :stuck_out_tongue:

What are you using to draw that circle? I am not 100% sure, but using ply:GetEyeTrace() and ply:GetAimVector() might make a difference. Idk, give it a try?

Take a look at the example in


The circle is drawn using ply:GetEyeTrace().

ply:SetEyeAngles() locks my vision no matter what from what it seems like.

Have you tried ply:GetAimVector? Like I said, it might work differently than ply:GetEyeTrace. I’m not sure, I haven’t actually looked at either functions code.

Yep, its just worse. Places the crosshair like 10 pixels up+right even in firstperson.

… Have you tried shooting a gun at the wall or something? Try it with both functions if you haven’t already. Perhaps the position you have is correct, and if the bullet impact is on point with the cross-hair you made, then you’re fine.

Well the place the crosshair is located is where the bullets go when I shoot, but I want the player to look towards the vector that is in middle of the screen rather than straight forward from the camera.

Oh. Now I understand. This thread should help you alot.

I was actually misinterpreting what your question was. Read through that thread. Should help a bunch. :slight_smile:

Sorry, should have said this first: skip towards the bottom. The bs about trig is irrelevant to this situation. Just take a look at the mans solution.

Just realized that it was a really stupid idea to do that haha. The player will look on everything that gets in front of the camera, so walking close to walls will cause the player to stop and walk backwards/into the wall.

This is an over-the-shoulder thirdperson I made a while ago. It should probably help you.

local OldAngles = EyeAngles()
local ThirdpersonAngles = EyeAngles()

local Minimum = Vector(-5, -5, -5)
local Maximum = Vector(5, 5, 5)

local Enabled = CreateClientConVar("thirdperson_enabled", "0")
local Distance = CreateClientConVar("thirdperson_distance", "100")
local Offset = CreateClientConVar("thirdperson_offset", "20")

local Thirdperson = function(ply, origin, angles)
	if !(Enabled:GetBool()) then return end
	if (ply:GetMoveType() == MOVETYPE_OBSERVER) then return end

	local view = {}
	local trace = {}
	local ShootPos = ply:GetShootPos()

	angles = ThirdpersonAngles
	ThirdpersonAngles = ThirdpersonAngles + (ply:EyeAngles() - OldAngles)

	local trace = util.TraceHull({
		start = origin,
		endpos = origin - (angles:Forward() * Distance:GetInt()) + (angles:Right() * Offset:GetInt()),
		mins = Minimum,
		maxs = Maximum,
		filter = {me},

	if (Distance:GetInt() < 0) then
		angles.p = -angles.p
		angles.y = angles.y + 180

		local ang = (trace.HitPos - ShootPos):Angle()
		local trace2 = util.TraceLine({
			start = trace.HitPos,
			endpos = angles:Forward() * 0x7FFFFFFF,
			mask = MASK_SHOT,
			filter = {me},

		local ang = (trace2.HitPos - ShootPos):Angle()

	OldAngles = ply:EyeAngles()

	view.origin = trace.HitPos
	view.drawviewer = true
	view.angles = angles

	return view

local MoveFix = function(cmd)
	if !(Enabled:GetBool()) then return end

	local me = LocalPlayer()

	if !(IsValid(me)) then return end
	if (me:GetMoveType() == MOVETYPE_OBSERVER) then return end

	vel = Vector(cmd:GetForwardMove(), cmd:GetSideMove(), 0)
	vel:Rotate(me:EyeAngles() - ThirdpersonAngles)


hook.Add("CalcView", "Thirdperson", Thirdperson)
hook.Add("CreateMove", "Thirdperson Movement Fix", MoveFix)

Not really, got a fully working one already just wanted to improve the aiming bit. Thanks anyways. :slight_smile:

The code I posted corrects the aim too.