How would I constantly zoom in and out with the camera?
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:
01 | local Unity = require(game.ReplicatedStorage:WaitForChild( "Unity.Api" ))() |
02 | local Project_Arkadata = Unity:InitializeApplication( "ArKaDatTa" ) |
06 | local RunService = game:GetService( "RunService" ) |
08 | local Player = game.Players.LocalPlayer |
09 | local Character = Player.Character or Player.CharacterAdded:wait() |
10 | local Camera = game.Workspace.CurrentCamera |
14 | Camera.Focus = Player.Character.HumanoidRootPart.CFrame |
16 | local function onRenderStepped() |
17 | local target = game.Workspace.Part |
18 | Camera.Focus = Player.Character.HumanoidRootPart.CFrame |
19 | Camera.CameraType = Enum.CameraType.Scriptable |
21 | local rootPart = Character.HumanoidRootPart |
22 | Camera.CFrame = CFrame.new(target.Position + rootPart.Position) * CFrame.new(- 18 , 2 , (Player:DistanceFromCharacter(target.Position))*offset) |
26 | local function onCharacterAdded(character) |
30 | local function ManageView() |
31 | for _,player in pairs (game.Players:GetChildren()) do |
32 | local bool = Camera:WorldToViewportPoint(player.Character:WaitForChild( "HumanoidRootPart" ).Position) |
40 | if not game:GetRemoteBuildMode() then |
41 | onCharacterAdded(Character) |
45 | Player.CharacterAdded:connect(onCharacterAdded) |