Unable to accurately set Camera CFrame in CameraType Watch

camerascript

#1

Hey all,
I’m not sure if this is a “bug” or not, so I’m putting it in the support category for now.
For some reason, as of recently [the last couple days or so, I’m not quite sure when exactly], I have been unable to accurately set the CFrame of the players CurrentCamera when the camera is in any mode other than Scriptable. I’m not sure if this is an intended effect, but it is certainly new and I’m a little concerned. Two of my cut scenes for Escape Room positioned the players’ camera while it was in the CameraType “Watch”, to create the effect that the stationary camera followed the player as they moved. However, now this code breaks and does not put the camera at the proper CFrame.

LocalScript Code in PlayerGui:

camera = game.Workspace.CurrentCamera   
camera.CFrame = game.Workspace.CameraPart.CFrame

CameraType = Enum.CameraType.Custom [Wrong CFrame/Position]:

CameraType = Enum.CameraType.Watch [No effect]:

CameraType = Enum.CameraType.Scriptable

Only when the CameraType is Scriptable does the expected result occur.
Please let me know if I am simply being dumb, and what I should be doing, or if this is an issue.
Thanks Guys!
Dev.


Unable to set CFrame of Camera if Type Enum.CameraType.Watch
#2

You are simply being dumb! Just kidding :joy:

The behavior you are experiencing is as intended. All camera types except for Scriptable have default behaviors from the Roblox engine. If you do not have the CameraType property set to Scriptable, then you may get no results or results that are unexpected when making changes to other camera properties.

This Wiki page has more information on the default behaviors of each camera type.


#3

Okay. But this must be a fairly recent change [last couple months] since I KNOW this worked in November/December of last year. What method would I use to achieve a similar effect to what I had then? I want the effect of the Watch CameraType, but from a point of my choosing. I.E… Setting the… Camera CFrame… ;-;
Is this no longer possible?


#4

As far as I am aware, there haven’t been any recent changes to the camera at all.

If you’re looking to set the CFrame of the camera, then you will need to set the CameraType to Scriptable for it to work as expected. The reason you cannot set the CFrame property of the camera while it is set to Watch is because the default behavior of the Watch property is for the camera to follow the CameraSubject.


#5

This is the desired effect [example]

This worked up until quite recently. Notice how the camera tracks the player while remaining stationary. I still have the subject set properly, and I simply set the CFrame for position.

I suppose I’ll just find someway to replicate this using interpolate :confused:


#6

Sorry about that, I was thinking of the wrong behavior for the Watch property. The CFrame property should be settable even when the CameraType is Watch, however, this may be a Roblox bug as it did not set the expected CFrame for me.

I would recommend filing a bug report so a Roblox engineer is able to look further into this.


#7

Okay Thanks - I thought that might be the case. I was actually surprised when you said it was expected behavior, as watch seems pretty useless if you can’t set the CFrame :slight_smile:
I’ll write a bug report up in a second. For now I wrote this which, while slightly CPU intensive, has the desired result:


#8

I’ve looked into this, and checked in fixes for the behavior that affect camera types Watch and Fixed. Both should allow setting the CFrame to reposition the cameras.

Both of these issues are a consequence of the Lua implementations not exactly matching the behavior of their C++ predecessors.


#9

WatchCamera doesn’t do a whole lot more than this. Instead of a while true loop though, you should do this on RenderStepped. You should also set camera.Focus to where you need it, the logical options being the CFrame of the camera if it’s a wide-angle view, so that lighting and LoD system updates are centered at the camera, or possibly the character position if you’re using a small field of view to watch the character closely (as if through a telescope), as it might make more sense to have the lighting grid updates centered there.