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

How do I get/calculate "Natural" or "Extended" Camera Distance from Subject?

Asked by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
9 years ago

I want to do something conditionally based on the player being zoomed to the maximum out (I have CameraMaxZoomDistance set to 18).

Right now, I have this line:

if (camera.CoordinateFrame.p - character.Head.Position).magnitude > 17 then

This works normally (more or less). However, it doesn't work if there's some object in the way of the camera. Since ROBLOX bumps the camera in so that you can't see through objects, the distance reported by this calculation is much less than the "natural" or "extended" camera distance which it will grow to in open space.

Is there any way to guess / calculuate that full distance or other workaround to estimate it?

It would also be nice since every few frames it seems like there can be a bit of delay and the camera will be reported slightly closer or farther than the range it's supposed to be (even in open space)

0
I'm not sure if I understand what is being asked, but when the camera is at the max zoom distance, it should never go over it. It's automatic. Tkdriverx 514 — 9y
0
No, but it can go under it, because of objects in the way of the camera. BlueTaslem 18071 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

Well, the only method I can think of is using the WheelBackward and WheelForward to record how far or close the camera will move from the Character's head. That way, even if an object is in the way, you'll know how far the camera will be from the Head if that object wasn't there.

However, I do want to note that the Change in camera distance isn't linear, but exponential, so you'll have to do some math along with the programming.

Ad

Answer this question