#Camera Position gets Jumpy when reaching the limit

1 messages · Page 1 of 1 (latest)

wet oak
#

Good evening skibidi

For some GOOBERISH reason my camera position just starts getting a little jumpy when it hits the rotation limit of the Camera
I’ve tried everything I know of, such as trying to use attachments which did work however it couldn’t be affected by the Humanoid Camera Offset


runService:BindToRenderStep("alt" , Enum.RenderPriority.Camera.Value+1, function(dt)
    local cameraCFrame = root.CFrame:ToObjectSpace(camera.CFrame)
    local x, y, z = cameraCFrame:ToOrientation()

    local ylimit = math.rad(math.clamp(math.deg(y), -limit, limit))

    local targetCFrame = root.CFrame:ToWorldSpace(CFrame.fromOrientation(x, ylimit, z))
    targetCFrame = CFrame.new(camera.CFrame.Position) * targetCFrame.Rotation
            
    camera.CFrame = targetCFrame
end)

I'd appreciate the help!
also if you're still confused, please pardon my grammar 🙏

icy musk
#

Why not clamp the rad value directly?

#

A radian is 1/TAU revolutions

#

Tau being 2 * PI

#

Also I can turn my head a full 90 degrees either side, and look straight down, not straight up though

#

My head tilts maybe 70-75 degrees upwards

wet oak
#

oh yeah i remember

#

if it works it works 💔

#

wait a minute

wet oak
icy musk
#
    local ylimit = math.rad(math.clamp(math.deg(y), -limit, limit))

This line converts Y from rad to degrees, then clamps it and converts it back into radians does it not?

#

Or is it the other way around

icy musk
#

If -limit and limit are in rads then

local ylimit = math.clamp(y, -limit, limit)
#

Lemme guess . . .

#

Y is in degrees 💔

#

😭 Alr nvm I'm a little slow sometimes

wet oak
#

you alr

#

wait.

#

wait a minute

#

why are we talking about the ylimits?

#

the rotation works very well it does its job of limiting the camera rotation without looking glitchy

icy musk
#

lmao

#

I called it out 'cause I thought it looked ugly as fuck

wet oak
#

the issue is that the camera position just starts TWEAKIN (as in starts stutter) when i just keep moving my mouse to whatever direction its limit

wet oak
icy musk
#

You'll probably have to do a bit 'o math and clamp the position of the camera too

#

It looks like it's the cam position is what's glitching

wet oak
#

yeah

#

i should prob debug and print the camera Position

#

see what silly gooberish shit be happening in my doodoo code broski

icy musk
#

If you'd rather, not saying you 100% should, you can use RunService.PreRender

local RunService = Game:GetService("RunService")

RunService.PreRender:Connect(function(_: number)
    -- Stuff here is run after everything bound to RenderStep using :BindToRenderStep(), but before the frame is rendered
end)
wet oak
#

i never heard of prerender

icy musk
#

Interesting . . .

#

Here is the RunService documentation

wet oak
#

seems interesting

wet oak
#

ight nvm all good!

#

i just simply remade roblox default camera and add freelookign and it works great