I’m working on a helmet cam system, and I decided to use a custom camera movement system, the way i did that was by attaching the camera to the characters head, and rotating the head and body depending on the delta of the mouse
here’s my code
-- Player --
local Player = game.Players.LocalPlayer
local Character : Model = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart : Part = Character:WaitForChild("HumanoidRootPart")
local Camera = workspace.CurrentCamera
-- Services --
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
RunService.RenderStepped:Connect(function()
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter;
local Delta = UserInputService:GetMouseDelta()
HumanoidRootPart.CFrame = HumanoidRootPart.CFrame * CFrame.Angles(0,math.rad(HumanoidRootPart.CFrame.Rotation.Y - (Delta.X / 2)),0)
Character.Torso.Neck.C1 = Character.Torso.Neck.C1 * CFrame.fromOrientation(math.rad(Character.Torso.Neck.C1.Rotation.X - (Delta.Y / 2)),0,0)
end)
So far it works really well, its very smooth, although i don’t really know how i can stop the character from doing a 360 while turning upwards or downwards, it’s pretty annoying honestly. I tried using math.clamp() but it’s not really working
(Delta.X / 2)),0)
I feel like you should mess with these numbers and see what happens
i mean it really just controls the speed, i’m dividing it so you don’t turn too fast
speed of the rotation?
the sensitivity of the mouse
3-0
not sure what u mean by the sensitivity of the mouse, because there is a built in feature
ig divide it by 3 and see if there’s a difference
i’m getting the delta of the mouse and applying it to the rotation of the camera, i’m dividing the delta in half so the camera turns slower
hold up i just wanna clarify, when you turn your camera upwards, it will do a 360?
yeah, theres no limit to how far you can turn
I did it by keeping rotation as a seperate variable, heres the code in case anyone wants to use it
-- Player --
local Player = game.Players.LocalPlayer
local Character : Model = Player.Character
local Humanoid = Character:WaitForChild("Humanoid")
local HumanoidRootPart : Part = Character:WaitForChild("HumanoidRootPart")
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
-- Services --
local UserInputService = game:GetService("UserInputService")
local RunService = game:GetService("RunService")
-- Variables --
local Debounce = false
Humanoid.AutoRotate = false
local CurRotation = 0
local MaxRotation = 70
local CameraModeConfig = {
HelmetCam = {
CameraCFrame = CFrame.new(0.922,0.641,0.042) * CFrame.Angles(math.rad(-15),0,0);
MaxRot = 70
};
HeadCam = {
CameraCFrame = CFrame.new(0,0.396,-0.5) * CFrame.Angles(math.rad(-5),0,0);
MaxRot = 70
};
ThirdPersonCam = {
CameraCFrame = CFrame.new(2,0.396,5) * CFrame.Angles(math.rad(-5),0,0);
MaxRot = 80
};
}
local CameraMode = "HelmetCam"
MaxRotation = CameraModeConfig[CameraMode].MaxRot
RunService.RenderStepped:Connect(function()
UserInputService.MouseBehavior = Enum.MouseBehavior.LockCenter;
local Delta = UserInputService:GetMouseDelta()
HumanoidRootPart.CFrame = HumanoidRootPart.CFrame * CFrame.Angles(0,math.rad(HumanoidRootPart.CFrame.Rotation.Y - (Delta.X / 2)),0)
CurRotation = math.clamp(CurRotation - (Delta.Y / 3),-MaxRotation,MaxRotation)
Character.Torso.Neck.C1 = CFrame.new(0,-0.5,0) * CFrame.fromOrientation(math.rad(-90 - CurRotation),0,math.rad(180))
Camera.CFrame = Character.Head.CFrame * CameraModeConfig[CameraMode].CameraCFrame
end)
keep in mind it only works for R6, and probably needs improvement