Making cool camera rotation around player [SOLVED]

What you’re doing in this code is adding the current player’s head position to the rotating camera, which will put the camera way off of where it should be.

First do your extra math in a second line of code so it’s easier to follow.

-- Seperate the math into different lines of code
local newCF = CFrame.lookAt(center.Position
				+ math.sin(angle) * Vector3.zAxis * radius
				+ math.cos(angle) * Vector3.xAxis * radius,
				center.Position)

newCF *= CFrame.new(0, positionOfHead.Y, 0)

You are adding the distance between the player’s head and the ground to the camera that is already near the player, so the camera will shoot up into the sky! Add the difference between the newCF position and the head position instead:

-- Replace the second line with:
newCF *= CFrame.new(0, positionOfHead.Y - newCF.Position.Y, 0)
3 Likes