CameraSubject keeps getting set to Humanoid every frame, even though the player’s charater is deleted, and the CameraType is Scriptable, It’s making setting Focus to a good number impossible unless I do so on a RenderStepped loop
Can you attach a repro?
Not an attachment, but the minimal repro is simple enough script that it doesn’t matter
LocalScript in any local environment:
local RunService = game:GetService("RunService")
local Camera = game.Workspace.CurrentCamera
local function UpdateCamera()
Camera.CameraType = "Scriptable"
Camera.CameraSubject = nil
Camera.CoordinateFrame = CFrame.Angles(0,math.pi/4,0)
Camera.Focus = Camera.CoordinateFrame-Vector3.new(0,Camera.CoordinateFrame.p.Y,0)
print(Camera.Focus.p.X) -- Correct print, due to the recent 'CameraSubject = nil'
wait()
print(Camera.Focus.p.X) -- Incorrect print, due to CameraSubject being set to Humanoid and goofed
end
while true do
UpdateCamera()
RunService.RenderStepped:wait()
end
[strike]Edit: Repro faulty, missing something relevant from my game’s place, as when tested in a baseplate place it does not reproduce the error, will post with what I find[/strike]
Wasn’t reproing in an empty game because the camera was aligned with the Character when it spawned, it will repro in a baseplate now
The problem is
Camera.CameraSubject = nil
Doesn’t actually work. You can set the camera subject to a dummy part wherever you need the focus to be as a quick fix. I will look into making it so the CameraSubject actually can be set to nil.
[quote] The problem is
Camera.CameraSubject = nil
Doesn’t actually work. You can set the camera subject to a dummy part wherever you need the focus to be as a quick fix. I will look into making it so the CameraSubject actually can be set to nil. [/quote]
Or at the minimum throw a warning so the script doesn’t silently fail to work, and update the wiki with information that Subject can’t be nil. Otherwise the bug is hard to trace.
Your workaround is not correct, setting CameraSubject to a part centred where I want it does not set Focus to that part, instead the focus is on the Camera’s CFrame still. Setting CameraSubject should override Focus like it says on the wiki, but it does not, please fix this too while you’re at it :DDD
Unfortunately I don’t think I will be able to change the behaviour of the focus for the scriptable camera type. Is using the custom camera type possible for you as this will let you set the focus manually and does not set the focus to the camera subject?
I just came across this issue. ROBLOX’s C++ camera code (yes there’s still some) is mucking around with my tweaks. It turns out it’s because the CameraSubject is set to something that’s in my character – since ROBLOX detects the subject as a character, it keeps moving and rotating the HumanoidRootPart when the camera moves/rotates for all camera types. To prevent this, I need to set CameraSubject to something that’s not in the character.
Preferably I’d set it to nil, but it’s not possible to set CameraSubject to nil. Right now I have it set to Workspace and that’s worked well so far, but that doesn’t sit well with me and I’m not sure what the side effects of that may be. It’d be great if I could set CameraSubject to nil – any camera type works for me since I can edit it in CameraScript.
Does this rotating of the humanoid root part happen even when the camera type is scriptable? If so, that is definitely a bug and I will fix it. (please post a repro). The only special case C++ code that should happen when the camera type is Scriptable is setting the focus 20 studs ahead. I looked into removing that last summer, but it would break some games.
I set ScriptableCamera’s source to ClassicCamera’s source in the starter camera script. I thought the issue was C++ listening for CameraType changes, but that wasn’t the case. I missed lines 277 and 282 in RootCamera which set GameSettings.RotationType, which I posted more about on the other thread. Sorry for the trouble!