Engine bug? CFraming the Camera kills the Character

I don’t have access to #bug-reports so I had to post here.

I tried to achieve a birds-eye view of the character with a fixed Y coordinate, so before lerping I started small, this is the LocalScript I used in StarterCharacterScripts:

local Camera = workspace:WaitForChild( "Camera" )
local Head = script.Parent:WaitForChild( "Head" )

local headPosition

Camera.CameraType = Enum.CameraType.Scriptable

game:GetService("RunService").Heartbeat:Connect( function()
	headPosition = Head.Position
	Camera.CFrame = CFrame.new( Vector3.new( headPosition.X, 24, headPosition.Z ), headPosition )
end )

This repeatedly kills the Character, instantly ( sometimes after a split-second ) after spawning, and not just that - it also makes it vanish. If I switch to server-view the Character stays alive and well, but as soon as I switch back to the client it goes back into the endless death loop.

A couple more things to note: doing print( Head ) finds the object all the way through, however doing print( Head.Position ) goes to NAN, NAN, NAN after just a few prints, and setting the Camera’s CFrame to Head.Position + Vector3.new( 0, 24, 0 ) doesn’t kill the Character - however this is not what I want to achieve.

No wait helped, like waiting for the Character to become a descendant of workspace or waiting for Camera.CameraType to register as Scriptable.

Tested and confirmed by multiple people, we’re all puzzled.

1 Like

Another thing I just tested that’s interesting to note:

Camera.CFrame = CFrame.new( Vector3.new( headPosition.X + 0.1 , 24, headPosition.Z ), headPosition )

That doesn’t kill the Character, so it only happens when the Camera is directly overhead.

Now I could go with this, as + 0.1 studs is not a noticeable difference ( probably would work with even less ), however the issue is too interesting to let go of at this point.

Don’t do CFrame.new for this scenario

At high pitch angles (around 82 degrees), you may experience numerical instability. If this is an issue, or if you require a different up vector, it’s recommended you use CFrame.fromMatrix instead to more accurately construct the CFrame. Additionally, if lookAt is directly above pos (pitch angle of 90 degrees) the up vector switches to the X-axis.

But I believe the bug is when the head position becomes NAN due to this and killing the character when only the camera position is changed.

1 Like

Oof, I actually completely forgot that CFrame.new was replaced, I shouldn’t be using it at all…
But yeah, the issue still remains.