How do i make my camera follow my head?

Hey, i was playing untitled tag game, and if you dont know theres like some kind of rolling and sliding but when you preform one of those the camera follows the head (also with emotes)
here is some clips:



(sorry for the lag, my pc is a potato lol)

so i by far looked for something like that, but everything i found didnt let me move my camera, so any help is appreciated!

1 Like

I think are setting the cam cframe to the head cframe in a run service function

yeah, the thing is that if i do that it will just loop it, so it will make it so i cant move my camera anywhere but the head’s, position.

You can set the Camera.CameraType to Enum.CameraType.Attach with a script and set the Camera.CameraSubject to the character’s head part.

I would do this in a LocalScript inside StarterCharacterScripts. Make sure to wait for the head to load before trying to set the camera subject.

Yep :sweat_smile: Nice catch, I fixed that in the reply.

did you mean CameraType?
Also it didn’t work, it just doesnt let me move my camera…

1 Like

i think op wants the angle to be tilted the way the head tilts but also to have freedom to look around. maybe restrain the cam during events where it moves?

2 Likes

ohh, thats a good idea ngl, but to be quick, i just wanna change the orientation of the camera to the head’s orientation, but i only saw cam.CFrame:ToEulerAnglesXYZ() and idk how to implement that or what is even that, ill check if what u did works, thx!

it worked!!! thxxxx:D

btw here is the code:

local p = game.Players.LocalPlayer
local c = p.Character or p.CharacterAdded:Wait()
local cam = game.Workspace.CurrentCamera
local m = p:GetMouse()

cam.FieldOfView = 80

--- Hide the player's accessories in first person, or they will cover our screen!

local doCamAttatch = false
local currentCamCframe = cam.CFrame

game.ReplicatedStorage.AttachCamToHead.Event:Connect(function()
	currentCamCframe = cam.CFrame
	doCamAttatch = true
	c.Humanoid.AutoRotate = false
	for i,v in pairs(c:GetChildren()) do
		if v:IsA("Accessory") then
			v.Handle.Transparency = 1
		end
	end
end)

game.ReplicatedStorage.UnAttachCamToHead.Event:Connect(function()
	cam.CFrame = currentCamCframe
	doCamAttatch = false
	c.Humanoid.AutoRotate = true
	for i,v in pairs(c:GetChildren()) do
		if v:IsA("Accessory") then
			v.Handle.Transparency = 0
		end
	end
end)

game["Run Service"].RenderStepped:Connect(function()
	if doCamAttatch then
		if c and c:FindFirstChild("Head") then

			local mouse_position = Vector2.new(m.X,m.Y)

			---- Calculate how far from the centre of the screen the player's mouse is
			local screen_size = cam.ViewportSize
			local mouse_centre_offset = (mouse_position/screen_size)-Vector2.new(0.5,0.5)

			local mouse_camera_rotation = CFrame.Angles(-mouse_centre_offset.Y,-mouse_centre_offset.X,0)

			cam.CFrame = c.Head.CFrame*CFrame.new(0,0.25,-0.375)*mouse_camera_rotation
		end
	end	
end)

(and the 2 bindableEvents) anyways tysm! have a great day!

1 Like

lol, anyways thanks for your help! :DD

1 Like

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