Hello, I was finishing some things for the player camera in a ROBLOX horror game I was making, and so far everything was good, except one thing; you can spin the camera without a limit, which isn’t a cool detail.
So I noticed a roblox game called “DOORS” prevented that when ingame, by having a rotation limit being applied when spinning too fast. I also noticed tiny details into it such as this specific one:
If the camera spins very fast immediately, the rotation will be fast but at a slow rate, instead if you gradually go up until you’re spinning very fast again, the rotation rate will be faster than the instant one.
This is one time where I can’t figure something like that out because either i’m bad at researching or I haven’t scripted with camera enough to know this. Also no i’m not talking about the camera sway effect, but the speed rate limit, this is an example footage if anyone can help me out:
This is not working at the current state, but the idea is, that you each frame update their camera orientation, and does so the angle can maximum be -10 or +10 in each direction of oldCameraAngle.
Math.clamp can be used to keep a number between a min & max value. Ect:
Nope i’m not looking for a sensitivity limit, i’m looking for a rotation speed limit like you see in the video, where my sensitivity is the same, but if i go ahead of a certain speed it doesnt go that fast
Well,
I’m still uncertain what effect you’re trying to achieve, since the script above limits how fast you can rotate the camera in first person. Hopefully you’ll figure it out.
try using a function bound to context action service
(this is a local script)
local ps = game:GetService('Players')
local pl = ps.LocalPlayer
local cas = game:GetService('ContextActionService')
pl.CharacterAdded:Connect(function(ch)
local hum = ch:WaitForChild("Humanoid")
local root = ch:WaitForChild("HumanoidRootPart")
local limit = 60
local camangx, camangy = 0, 0
local function playerInput(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Change then
camangx = math.clamp(camangx - inputObject.Delta.X, camangx - limit, camangx + limit)
camangy = math.clamp(camangy -inputObject.Delta.Y, camangy - limit, camangy + limit)
end
end
cas:BindAction("playerInput", playerInput, false, Enum.UserInputType.MouseMovement)
end)
(note this function does not update the camera and only tells the camera the value the mouse has been moved (clamped by the limit)