A recent change to the default PlayerModule has caused a bug. When you change the Camera’s CameraType (in my case, from Scriptable to Custom) the camera’s angle is reset to behind your character.
I have traced this bug to the Roblox-provided Module PlayerModule.CameraModule.BaseCamera
. It is the result of enabling FFlagUserOrganizeBaseCameraConnections
The Cause of the Bug
Every time a camera module that derives from BaseCamera
(including in our case, ClassicCamera
) becomes enabled, the method _setUpConfigurations
is called:
function BaseCamera:OnEnabledChanged()
if self.enabled then
if FFlagUserOrganizeBaseCameraConnections then
self:_setUpConfigurations() -- here
end
...
The method _setUpConfigurations
will call OnCharacterAdded
if the player has a Character:
if FFlagUserOrganizeBaseCameraConnections then
function BaseCamera:_setUpConfigurations()
self._connections:trackConnection(CONNECTIONS.CHARACTER_ADDED, player.CharacterAdded:Connect(function(char)
self:OnCharacterAdded(char)
end))
if player.Character then
self:OnCharacterAdded(player.Character) -- here
end
...
And finally, resetCameraAngle
is set to true
by OnCharacterAdded
:
function BaseCamera:OnCharacterAdded(char)
self.resetCameraAngle = self.resetCameraAngle or self:GetEnabled() -- here
...
The resetCameraAngle
property causes the camera angle to be reset the next time the camera’s Update
is invoked.
Reproducing the Bug
I have include a basic repro file. Press C to toggle your CameraType to Scriptable and back. You can see that it causes your camera’s angle to snap back behind your character.
CameraAngleResetRepro.rbxl (55.0 KB)
A Solution to the Bug
I think a good solution to this would be to make sure we haven’t already called OnCharacterAdded
for this Character:
function BaseCamera:OnCharacterAdded(char)
if char == self.lastCharacter then
return
end
self.lastCharacter = char
...
Expected behavior
It is understandable that the Camera’s focus would snap to your character (if necessary) when changing the CameraType from Scriptable to Custom, but it should not reset the Camera’s angle.