Attaching Camera to subject which is locked from rotating by user input

Is there a way to attach a camera to follow a subject without the ability to change the camera views rotation through RMB and drag? I have explored all of the camera types but none seem to meet this criteria. This makes me think that I’ll have to create a custom following system?

1 Like

You mean Enum.CameraType.Fixed?

Then it does not follow the subject. I just noticed that I only mentioned “Attached” and left out that criteria so I will edit my post; sorry about that.

Easiest way for me would be to set cameraType to Scriptable and manually set the cframe using RunService.RenderStepped

Edit: I should note that I am tracking an object running on a separate Heartbeat loop which is being moved using CFrames; so that is the cause of the jittering I think.

Yep, that was my alternative but sadly there is a noticeable jittering effect when zoomed in on the subject.

while Heartbeat:wait() do
	Camera.CoordinateFrame = CFrame.new((Subject.CFrame * CFrame.new(0, 100, 0)).p, Subject.CFrame.p)
end

Use BindToRenderStep, my dude. It stutters because the camera’s CFrame updates before the character’s position updates in a given frame. Optimally, you’d want the camera to update after the character has moved, not before.

RunService:BindToRenderStep (
    "camera", 
    Enum.RenderPriority.Camera.Value,
    function ()
        Camera.CFrame = CFrame.new((Subject.CFrame * CFrame.new(0, 100, 0)).p, Subject.CFrame.p)
    end
)

More on BindToRenderStep: http://wiki.roblox.com/index.php?title=API:Class/RunService/BindToRenderStep

1 Like

Awesome! I had no clue this was a thing, thanks for the help. :grinning: