Camera module errors every frame when VR is enabled

Whenever running in VR in Roblox Studio in an empty baseplate, the following error is emitted every frame.

The VR set is the HTC Vive Pro, on Windows 10, with Steam VR 1.15.12.

18:39:40.957 - RunService:fireRenderStepEarlyFunctions unexpected error while invoking callback: Players.Quenty.PlayerScripts.PlayerModule.CameraModule.ClassicCamera:284: attempt to call a nil value
  18:39:40.971 - Players.Quenty.PlayerScripts.PlayerModule.CameraModule.ClassicCamera:284: attempt to call a nil value
18:39:40.973 - Stack Begin
18:39:40.974 - Script 'Players.Quenty.PlayerScripts.PlayerModule.CameraModule.ClassicCamera', Line 284 - function Update
18:39:40.975 - Script 'Players.Quenty.PlayerScripts.PlayerModule.CameraModule', Line 522 - function Update
18:39:40.975 - Script 'Players.Quenty.PlayerScripts.PlayerModule.CameraModule', Line 161
6 Likes

Reproducible on Oculus Quest & Oculus Rift.

Can confirm I am reproducing this error with the following code, not sure what’s causing it:

local vr = {}
local VrService = game:GetService("VRService")
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Camera = workspace.CurrentCamera
local InVR = VrService.VREnabled
function SetUp()
	 if InVR then
		local HS = 1;
		Camera.HeadScale = 1;
		function vr:getcfs()
			local rhcf = VrService:GetUserCFrame(Enum.UserCFrame.RightHand)
			local lhcf = VrService:GetUserCFrame(Enum.UserCFrame.LeftHand)
			local headcf = Camera:GetRenderCFrame();
			rhcf = (Camera.CFrame*CFrame.new(rhcf.p*HS))*CFrame.Angles(rhcf:ToEulerAnglesXYZ())
			lhcf = (Camera.CFrame*CFrame.new(lhcf.p*HS))*CFrame.Angles(lhcf:ToEulerAnglesXYZ())
			return headcf,rhcf,lhcf
		end

		local FakeModel = Instance.new("Model");
		local H = Instance.new("Humanoid");
 
		local RightArm = Instance.new("Part");
		RightArm.Name = "Right Arm";
		RightArm.Size = Vector3.new(1, 2, 1) * .5; -- 50% reduction from normal arm size..
		RightArm.Material = "SmoothPlastic"
		RightArm.Anchored = true;
		RightArm.CanCollide = false;
		RightArm.LocalTransparencyModifier = 0;
		RightArm.BrickColor = Character.Head.BrickColor
		local LeftArm = RightArm:Clone();
		LeftArm.Name = "Left Arm"
 
		RightArm.Parent,LeftArm.Parent,H.Parent = FakeModel, FakeModel, FakeModel -- this literally does the same thing as 3 declarations pls.
 
		vr.Model = FakeModel;
	end
end
 local VRS = VrService
function mainLoop(...)
	if InVR then
 
		local head_pos, rh_pos, lh_pos = vr:getcfs(); -- this is where we align the models with the hands and stuff
		-- THESE ARE IN WORLD SPACE!
 
		local rawRightHandCFObjectSpace = VRS:GetUserCFrame(Enum.UserCFrame.RightHand)
		local rawLeftHandCFObjectSpace = VRS:GetUserCFrame(Enum.UserCFrame.LeftHand)
 
		local FakeModel = vr.Model;
		local rh = FakeModel:FindFirstChild("Right Arm");
		local lh = FakeModel:FindFirstChild("Left Arm");
 
		lh.CFrame = lh_pos * CFrame.Angles(math.rad(90), 0, 0);
		rh.CFrame = rh_pos * CFrame.Angles(math.rad(90), 0, 0);
		FakeModel.Parent = Character;
		
	end
end    
SetUp()
game:GetService("RunService"):BindToRenderStep("VRUpdate",1,mainLoop)

It seems to be related to this section of the CameraModule code:

– Only move the camera if it exceeded a maximum distance to the subject in VR
if distToSubject > zoom or flaggedRotateInput.x ~= 0 then
local desiredDist = math.min(distToSubject, zoom)
if FFlagUserCameraInputRefactor then
vecToSubject = self:CalculateNewLookFromArg(nil, rotateInput) * desiredDist
else
vecToSubject = self:CalculateNewLookVector() * desiredDist
end
local newPos = cameraFocusP - vecToSubject
local desiredLookDir = camera.CFrame.lookVector
if flaggedRotateInput.x ~= 0 then
desiredLookDir = vecToSubject
end
local lookAt = Vector3.new(newPos.x + desiredLookDir.x, newPos.y, newPos.z + desiredLookDir.z)
if not FFlagUserCameraInputRefactor then
self.rotateInput = ZERO_VECTOR2
end
newCameraCFrame = CFrame.new(newPos, lookAt) + Vector3.new(0, cameraHeight, 0)
end

Most specifically this line:
vecToSubject = self:CalculateNewLookFromArg(nil, rotateInput) * desiredDist

1 Like

I had the same issue, although it didn’t seem to be causing any actual bugs within the game. It did go away automatically as soon as my VR Code loaded, but when I had an error preventing the code from progressing it would fill up my output and I couldn’t see the error. I’d recommend just pulling the camera code into edit mode and placing a pcall infront of the line iKrypto mentioned.

Hello, sorry to bump but I discovered the bug can be fixed by setting the camera to ‘Scriptable’. I figure the default camera mode is NOT compatible with VR although it has broken code to emulate such a feature.

Good luck everyone!

1 Like

Side note: I verified this still exists as of yesterday.

Thanks for the report! We’ve filed a ticket to our internal database and we’ll follow up when we have an update for you.

Please note that filling a bug report does not guarantee that it will be fixed once triaged.

2 Likes

Thanks!

If I suggest a minimal back fix, would this be something you would be willing to accept? This bug is very annoying, and a fix is basically an if-statement away.

Hey @Quenty Sorry for the delayed response. If you want to provide that, i can pass it to the engineers but that’s not a guarantee that they will use it

2 Likes

Right, let me take a look tomorrow. It might already be fixed.

Let me know when you have had a chance to check.

Sorry for the delay! It’s fixed!

This issue should now be resolved! If this issue is still occurring, please create a new topic for us to look into.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.