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

How would I constantly zoom in and out with the camera?

Asked by 8 years ago

Hold your horses!

The question may seem simple - but as it's 11:30 where I'm at and I got a brainfart, I just need some help. See, I am using WorldToViewportPoint and the camera's interpolate method - but...

...I do not know how to go about getting the players inside the game and constantly changing the camera with a loop/event to get it show all players while not making the camera FoV excessively large.

Kind of like Brawlhalla's camera where it constantly expands and decreases its range to fit all players within the screen. It zooms in when they're all bundled and zooms out when they're not.

Yeah, I'm using BindToRenderStep if you were wondering as well. Pretty neat feature.

Anyways, thanks for helping.

Here's the code:

01local Unity = require(game.ReplicatedStorage:WaitForChild("Unity.Api"))() --Ignore
02local Project_Arkadata = Unity:InitializeApplication("ArKaDatTa") --Ignore
03 
04--// Initialization
05 
06local RunService = game:GetService("RunService")
07 
08local Player = game.Players.LocalPlayer
09local Character = Player.Character or Player.CharacterAdded:wait()
10local Camera = game.Workspace.CurrentCamera
11 
12local offset = 2 --Me thinking of ways to manipulate camera to zoom in and out
13 
14Camera.Focus        = Player.Character.HumanoidRootPart.CFrame
15 
View all 45 lines...
0
tl;dr - More so looking for an efficient idea/method/algorithm to go about with this. AbstractCode 16 — 8y
0
Get the distance between the two farthest players and try to fit those two on the screen? Overscores 381 — 8y
0
Yeah, I was thinking about something like that. Using a loop to find the players with the largest distances or make it relative to the distance of the farthest player. Just wanted to see if there were any more efficient methods. AbstractCode 16 — 8y

Answer this question