Camera's zoom distance reset on type change

Hello. I’ve been doing some very basic camera manipulation in order to position the player’s camera over a counter-like object. And although I have achieved this to my liking, I ran into a problem that I can’t seem to figure out the answer to.

When switching the camera’s type from custom to scriptable and then back to custom it seems to suddenly reposition the camera’s zoom distance back to what it was originally. Here is a gif of the issue


https://i.gyazo.com/c5762de8df992d9bc3f2bbb680a07512.mp4

I am pretty much just tweening the camera behind the counter(while also teleporting the player’s character behind the counter) and then when the player is done I tween the camera to a specific CFrame behind the character. After this final tween, I then set the camera back to its normal self.

Once I set the camera back to its normal self(Camera.CameraType = Enum.CameraType.Custom) that sudden frame jump to the original zoom distance occurs. Changing the camera’s subject has nothing to do with this problem either.

I would like a smooth transition from scriptable to custom without the camera’s zoom distance being changed at all.

I have tried manually setting the CFrame back to the final tween CFrame but as you can guess, that didn’t work. I have also tried manually setting the Camera’s Zoom. Course, we don’t have permission to do so. So I am sorta at a loss.

I am not sure if there is a fix to this other than scripting my own camera system, but when all hope is lost, I figured I’d see if any other developers have faced this problem and came up with a solution of their own.

Thank you very much!

You could try setting the Player’s MaxZoomDistance to a lower number. By default this is 200. The level you are trying to achieve I think is around 50. It is a property of the player object. Link to wiki page: https://developer.roblox.com/en-us/api-reference/property/Player/CameraMaxZoomDistance

1 Like

Alright, thank you lots for the help! So I initially began using this method but found it just not working as well as I wanted it. Though, you mentioning this re-sparked my search into trying to figure this whole thing out.

For some reason…I didn’t think of just forking the CameraModule. So I went ahead and did that, and although it’s extremely messy right now for testing purposes, I used the equations that the default camera module uses to calculate the camera’s CFrame and position. Doing this resulted in a transition like this

I am pretty sure this is perfectly smooth now that I am getting the exact CFrame that will occur when the camera’s type switches. Of course, I got a lot more to do in order to make this work cleaner but I am glad I found the start to my solution!

Thank you so much!

1 Like