How to get current camera zoom level

I’ve mentioned it in the post

Char count

1 Like

Camera still flies away but in a strange way.

Here’s the code in case you are wondering.

Camera.CFrame = Camera.CFrame:Lerp(Goal, 1 - time() ^ DeltaTime)

I mean the t being the amount of seconds to lerp, kind of like the first parameter in TweenInfo.new()

1 Like

Also we should also make sure that my code works properly since i cant test it, so disable this script, and then create a new LocalScript inside of starterCharacterScripts and paste the example code i provided:

local RunService = game:GetService("RunService")
local cam = workspace.CurrentCamera
local head = script.Parent:WaitForChild('Head')

RunService.RenderStepped:Connect(function()
   -- zAxis is basically the equivalent of saying "Vector3.new(0,0,1)"
     local camZ = Vector3.zAxis *  cam.CFrame.Position
      local headZ = Vector3.zAxis * head.Position
      local magnitude = (camZ - headZ).Magnitude
      print('current zoom level: '..magnitude)
end)
1 Like

It has a bit of problem.
When I stand still and don’t do anything (I don’t even touch keyboard and mouse) the values it prints are different. They go between 12 and 13 (in my current zoom level case). That’s probably why camera flies away probably.

1 Like

I edited it, i just flipped the values so instead of headZ - camZ I changed it to camZ - headZ, not sure if it’ll fix it but worth a try

1 Like

Yep, it works now. Camera doesn’t fly away. However, the zoom in/out doesn’t work which is probably because it gets the distance between camera position and head position.

1 Like

I think I will just give up on it until I will find a solution.

1 Like

Your code doesnt look like to have a zooming functionaility, could you quote it so i can try to help?

1 Like

Well i guess you could mark this as a solution since its the main solution for the topic.

1 Like

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