[SOLVED] R6 Neck supposed to rotate the head, but it rotate the Torso instead

The pervious forum of this topic is too long, yeah no one will read that all and ignored it.
So i gonna make this topic again but more simpler and easier to understand

So i made first person camera with Scriptable camera and i want to add Head movement feature that look at the Xaxis (up-down) direction of Camera but i encounter the annoyest problem is "The motor6d call “Neck” that most dev used to rotate the head part, But in my case it rotate the torso instead of rotate the head like other do, it cause the problem make the body of player’s character lay down in horizontal and slide around.

I tried used Neck.C1 and it doesn’t solve and also tried parent the neck from torso to a head, of course it doesn’t solve

local RunService = game:GetService("RunService")
local UIS = game:GetService("UserInputService")
local CP = game:GetService("ContentProvider")

local Camera = workspace.CurrentCamera
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Humanoid = Character.Humanoid

local Hrp = Character.PrimaryPart
local Head = Character.Head
local Torso = Character.Torso
local neck = Torso:FindFirstChild("Neck")

local FirstPersonCameraHandler = {}

-- ConfigureCameraSystem
FirstPersonCameraHandler.FieldOfView = 90
FirstPersonCameraHandler.AspectRatio = 1.5
FirstPersonCameraHandler.CameraSensinity = Vector2.new(0.020,0.020)
FirstPersonCameraHandler.unlockMouseButton = Enum.KeyCode.F

FirstPersonCameraHandler.Connection = {}

--FirstPersonCamera Config
local CameraRotation = Vector2.zero
local maxVecticalAngle = { Y = NumberRange.new(-math.rad(80),math.rad(80)) }

local CamOffset = Vector3.new(0,0.15,-1) 

local function UpdateCameraRotation(change)
	local mouseDelta = UIS:GetMouseDelta()
	
	CameraRotation =  Vector2.new(
		CameraRotation.X - mouseDelta.X * FirstPersonCameraHandler.CameraSensinity.X,
		math.clamp(
			CameraRotation.Y - mouseDelta.Y * FirstPersonCameraHandler.CameraSensinity.X,
			maxVecticalAngle.Y.Min,
			maxVecticalAngle.Y.Max
		)
	)
end

-- Method function
function FirstPersonCameraHandler:ChangeToFirstPersonView()
	CP:PreloadAsync(Character:GetDescendants())
	--[[
	Character.PrimaryPart = Hrp
	Head.Size = Vector3.new(1,1,1)
	neck.Parent = Head
	neck.Part0 = Character.Torso
	neck.Part1 = Character.Head
	neck.DesiredAngle = 0
	neck.MaxVelocity = 0
	Humanoid.AutoRotate = false
	wait()
	]]
	Camera.CameraType = Enum.CameraType.Scriptable
	UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
	UIS.WindowFocused:Connect(function()
		UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
	end)
	Player.CameraMinZoomDistance = 0.5
	Player.CameraMaxZoomDistance = 0.5
	Camera.FieldOfView = FirstPersonCameraHandler.FieldOfView
	SetLocalTransparencyOfCharacter(0)
	
	local yOffset = neck.C0.Y
	
	FirstPersonCameraHandler.Connection.CameraUpdate = 
		RunService:BindToRenderStep("CameraUpdated",Enum.RenderPriority.Camera.Value,function(dt)
			UpdateCameraRotation()
			 
			local CameraLookDirection = Camera.CFrame.LookVector
			
			local _,ry,rz = neck.C0:ToEulerAnglesXYZ()
			neck.C0 = CFrame.new(0,yOffset,0)*CFrame.Angles(math.asin(CameraLookDirection.Y) - math.rad(90),ry,rz) -- most of neccesary part of this topic
			
			local hrpY, hrpX, hrpZ = Hrp.CFrame:ToOrientation()
			local raw = Head.CFrame * CFrame.Angles(-hrpY,-hrpX,-hrpZ)
			local rot = CFrame.Angles(0,CameraRotation.X,0) * CFrame.Angles(CameraRotation.Y,0,0)
			
			Camera.CFrame = raw * rot * CFrame.new(0,0,5)
			Hrp.CFrame = CFrame.new(Hrp.Position)*CFrame.fromOrientation(0,CameraRotation.X,0) -- most of neccesary part of this topic
		end) 
end

Note: i wrote this script on the Module script, So i paste the neccessary thing in here.

If anyone read this PLEASE HELP, just do anything for like suggest, give tip, advice. I stuck with this thing for 4 weeks

I’m not an expert on this type of thing, but neck is a child of Torso, which would make the torso move, since you’re moving the neck. i don’t really know how this could possibly help, but maybe it’s just that you’re calling it from the wrong part, maybe you should look for anything in the head that would help

At least you replied my forum with advicing, I would find other way to rotate the head
from your advice. Thank you!

Neck is a joint, with two parts as input. It’s really only parented to torso to make it easier to find, as that’s where others joints are. (I think? It’s been a while since I’ve used joints.)

a solution might be to move the neck joint to the head, maybe that would work, just keep it in the same place, just in the head

I already used the solution, it doesn’t solve anything. I’m sorry

Thanl you for giving information and sorry for slow replied. This is first time ever that i messing around with the joint.

Try doing Char.PrimaryPart = Char.HumanoidRootPart

try modifying the C1 instead of C0, you may need to flip the rotation beforehand.

Holy Cow, it worked. I can’t believe the old solution will work by just make variable to direct reference to Character’s HumanoidRootpart and change The character model’s primarypart again. But it come with new problem :skull:, but still your solution solve my almost eternal problem anyway. Thank you so much

function FirstPersonCameraHandler:ChangeToFirstPersonView()
	CP:PreloadAsync(Character:GetDescendants())
	
	Character.PrimaryPart = Hrp
	Head.Size = Vector3.new(1,1,1)
	neck.Parent = Head
	neck.Part0 = Character.Torso
	neck.Part1 = Character.Head
	neck.DesiredAngle = 0
	neck.MaxVelocity = 0
	Humanoid.AutoRotate = false
	wait()
	
	Camera.CameraType = Enum.CameraType.Scriptable
	UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
	UIS.WindowFocused:Connect(function()
		UIS.MouseBehavior = Enum.MouseBehavior.LockCenter
	end)
	Player.CameraMinZoomDistance = 0.5
	Player.CameraMaxZoomDistance = 0.5
	Camera.FieldOfView = FirstPersonCameraHandler.FieldOfView
	SetLocalTransparencyOfCharacter(0)
	
	local yOffset = neck.C0.Y
	
	FirstPersonCameraHandler.Connection.CameraUpdate = 
		RunService:BindToRenderStep("CameraUpdated",Enum.RenderPriority.Camera.Value,function(dt)
			UpdateCameraRotation()
			
			local Rootpart = Character.PrimaryPart
			local CameraLookDirection = Rootpart.CFrame:ToObjectSpace(Camera.CFrame).LookVector
			
			local _,ry,rz = neck.C0:ToEulerAnglesXYZ()
			neck.C0 = CFrame.new(0,yOffset,0)*CFrame.Angles(math.asin(CameraLookDirection.Y) - math.rad(90),ry,rz)
			
			local hrpY, hrpX, hrpZ = Rootpart.CFrame:ToOrientation()
			local raw = Head.CFrame * CFrame.Angles(-hrpY,-hrpX,-hrpZ)
			local rot = CFrame.Angles(0,CameraRotation.X,0) * CFrame.Angles(CameraRotation.Y,0,0)
			
			Camera.CFrame = raw * rot
			Rootpart.CFrame = CFrame.new(Rootpart.Position)*CFrame.fromOrientation(0,CameraRotation.X,0)
			--Hrp.CFrame = CFrame.new(Hrp.CFrame.Position)
		end)
end

And also thank you too for advice this solution again, it work because i solve the unexpected problem that i should realize soon.

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