Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is there a way to get how far the player is zoomed in or out?

Asked by 9 years ago

Like CameraMaxZoomDistance or CameraMinZoomDistance? Is there one for current zoom distance?

1 answer

Log in to vote
2
Answered by
TaslemGuy 211 Moderation Voter
9 years ago

You can calculate it yourself!

Suppose that camera is the player's camera object, and head is the player's head (I'm skipping how we obtain them because it could vary depending on what you're doing).

To know how far apart they are, we'll find out where they are. The player's head will be at head.Position. The camera's position will be camera.CoordinateFrame.p since we want the position (p) of its CFrame (CoordinateFrame).

So to find the distance between them, subtract them. Then find the magnitude of the result.

Thus,

currentZoom = (camera.CoordinateFrame.p - head.Position).magnitude

This will be the distance (in studs) from the player's head (the origin of their camera) and their camera's location.

Ad

Answer this question