Restricting camera movement

Hello!

I was wondering if it was possible to restrict camera movement, and how would I do it? My CameraType is set to Attach, however you can still move your camera up and down, how would I stop this movement?

5 Likes

You need to use the Scriptable Camera Type

2 Likes

How would I keep it moving with the character though? Can I just add a weld?

1 Like

in scriptable it will freeze the camera in position and you can script on where it can be and etc. So you want the camera to move with the Character but the Character not being able to move the camera?

Edit: Also for some reason your video doesn’t play

2 Likes

I think you can parent the part inside the character

1 Like

I don’t really know
Im not used to this kind of scripting

1 Like

Negate changes to the Y component on RenderStepped. Break the Camera’s CFrame into rotational X, Y and Z components and store the Y when you first set the CameraType to Attach. Then, in RenderStepped, set the CFrame of the Camera to use the current X and Z components but ignore the Y. Might be wise to use BindToRenderStep with a value greater than that of Enum.RenderPriority.Camera.

5 Likes

Nah, I just want the camera to move with the character, but the camera shouldn’t be able to move without the character moving if that makes sense.

Thanks! I will read up on that as it’s new to me.

2 Likes

Here’s what I have so far, but it isn’t working for some reason.

local CC = workspace.CurrentCamera

local HRP = workspace:WaitForChild(game.Players.LocalPlayer.Name):WaitForChild('HumanoidRootPart')

CC.CameraType = Enum.CameraType.Attach

local function bindCamera()

CC.CFrame = CFrame.new(CC.CFrame.Position.X, 20, CC.CFrame.Position.Z)

end

Here’s the error:
RunService:fireRenderStepEarlyFunctions unexpected error while invoking callback: Position cannot be assigned to

2 Likes