So I've been thinking about how to replicate this into ROBLOX.
Let's grab all the players and find the centered position by finding the mean value of their Vector3 positions.
We will also grab the bounds by looping to find which players are the farthest in terms of x and y. Our z will be our "zoom" axis as that's what we'll use to zoom in and out.
Now:
We have our bounds and desired position/centre of the camera. The issue now comes how do we code this?
SSB has the camera zoom in and out based on the distances of characters relative to each other. I believe this is due to their focus box decreasing and expanding in size. ROBLOX's API is quite different from Unity's so I was wondering if anybody may help guide me into a proper route into manipulate the camera.
In addition, the Camera:Interpolate function seems broken as I can't seem to cast an instance of CFrame but using CFrame.new by itself is fine and the value exists.
My code thus far:
local RunService = game:GetService("RunService") local Camera = game.Workspace.CurrentCamera local Player = game.Players.LocalPlayer local function CalculateBounds() local X,Y = {}, {} for _,player in pairs (game.Players:GetChildren()) do local position = player.Character.HumanoidRootPart.Position table.insert(X, position.X) table.insert(Y, position.Y) end local desiredPosition = Vector3.new((math.min(unpack(X)) + math.max(unpack(X)))/2, (math.min(unpack(Y))+ math.max(unpack(Y)))/2, (math.min(unpack(Y))-math.max(unpack(X), unpack(Y)))/2*math.tan(90-Camera.FieldOfView/2)) Camera.CFrame = CFrame.new(desiredPosition.X, desiredPosition.Y, desiredPosition.Z) end local function FindAverageDistance() end local function Execute() CalculateBounds() end RunService:BindToRenderStep('Camera', Enum.RenderPriority.Camera.Value, Execute)
Now this is a bit empty as I want to get the bounds formula correct. I've been trying multiple was and still am.
Hey Objectly,
Here is some code that may help,
local target = workspace.Part local camera = workspace.CurrentCamera camera.CameraType = Enum.CameraType.Scriptable camera.CameraSubject = target local angle = 0 while wait() do camera.CoordinateFrame = CFrame.new(target.Position) --Start at the position of the part * CFrame.Angles(0, angle, 0) --Rotate by the angle * CFrame.new(0, 0, 5) --Move the camera backwards 5 units angle = angle + math.rad(1) end
This code is from the wiki.