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