So I've been trying to find on YT and Reddit and basically every media app and I can't seem to find help on how to make this. If you don't know what I'm talking about well basically the Smash Bro's camera takes the center of the character that is the furthest to the left and right so it adjusts the camera (zooming out) to fit those characters. Thank you!
How would someone make a Smash Bros Ultimate type of camera?
1 answer
i guess setting the x and y coordinates to be the average of all the player positions, and as for the z coordinate...
-get the average of all of the player's locations, we will call this averageVector
-have a sum, called TotalMagnitude
-loop through each player...
local c = game.Players:GetChildren()
local TotalVector = Vector3.new(0,0,0)
local length = 0
for i, plr in pairs(c) do
local char = plr.Character
if char then
TotalVector = TotalVector + char.PrimaryPart.Position
length = length + 1
end
end
local AverageVector = TotalVector/length
local TotalMagnitude
length = 0
for i, plr in pairs(c) do
local char = plr.Character
if char then
TotalMagnitude = TotalMagnitude + (char.PrimaryPart.Position - AverageVector).magnitude
length = length + 1
end
end
local averageMagnitude = TotalMagnitude/length
--Your X value for the camera is AverageVector.X
--Your Y value is AverageVector.Y
--Your Z value is averageMagnitude (if you want it to be a little further, then Z + 5 or something, same with X and Y)
What this is doing is taking each player's distance from all of the players' average location, and finding the average distance between them all. basically, the camera will move out the further the players get from eachother. as for the x and y, thats just the average of all the players' locations. I havent tested this, so you may need to make some tweaks once you add it.
EDIT: the code above does not move the camera, it is simply the math that gets the camera position. if you would like me to make a script that does this, i would be happy to do so
4 comments
It is your choice if you would want to.
also, to zoom in use camera field of view.
does this script work for you, or would you like me to make one
yes it works for me and sure you can.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Please be more specific on which part you don't get (the math, moving the camera, etc)
I am pretty confident on the math, the camera part no so much.