How to "reset" player's camera to it's original angle (=behind the char's head)

Hi, everyone!

  1. What do I want to achieve?
    Basically, the player is able to move his camera in different directions/angles. I would like to create a button which resets the camera behind the character’s head once clicked. Is that possible?
  2. What is the issue?
    I tried many times with different methodes but nothing seems to work.
  3. What solutions have you tried so far?
    I tried to search on the Internet and on the DevForum but without any answer to my struggle so far.

I would like to know if anyone knows how to do that, or at least the functions and/or processes needed to reach that effect.

I hope the way I explained what I want seems clear to you all. Thanks by advance for your help! :wink:

You can still change the CFrame of the player’s camera while it’s being controlled by the player. It will just cause the camera to “line up” with whatever location you set it to.

ezgif.com-video-to-gif

So, in theory, all you need to do is get the orientation of the player’s head, and then set the camera’s CFrame to that orientation.

local lp = game:GetService('Players').LocalPlayer
local angleOffset: CFrame = CFrame.Angles(math.rad(-30), 0, 0) --tilt the camera down a bit

script.Parent.MouseButton1Click:Connect(function()
	local char = lp.Character
	if char then
		local head: BasePart = char:FindFirstChild('Head')
		if head then
			workspace.CurrentCamera.CFrame = head.CFrame*angleOffset
		end
	end
end)

1 Like

Thanks a lot, this seems to be the best way to solve my problem!
Have a great day! :wink:

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