How do I get the camera to rotate 180° around the player?


I’m trying to get the camera to rotate around the player 180° around the player. I got the player to rotate using some fancy CFrame manipulation, but I can’t seem to get the camera to follow suit. Here’s the code that I have so far:

-- When triggered from the server, causes the camera to
-- rotate 180° about the player.
	local camera = game.Workspace.CurrentCamera
	local ctype = camera.CameraType
	camera.CameraType = Enum.CameraType.Scriptable
	camera.CFrame = camera.CFrame * CFrame.Angles(0, math.pi, 0)
	camera.CameraType = ctype

I’m going to continue to play with this code.

I think you could maybe do something like this:

local offset = camera.CFrame.Position - player.Character.Head.Position
camera.CFrame = CFrame.lookAt(player.Character.Head.Position +, offset.Y, -offset.Z), player.Character.Head.Position)

Basically, in this approach, you just move the camera to the opposite side across the player, then you point the camera at the player.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.