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

Creating a Super Smash Bros Camera?

Asked by 7 years ago
Edited 7 years ago

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.

0
You could try changing the field of view based on the distance between players. AZDev 590 — 7y
0
The problem with that is gives up a lot of the camera control I have. E.G. I don't want the camera to follow players who go out of a specific radius. Objectly 49 — 7y
2
Could you post an attempt? Otherwise we're basically making the script for you. Goulstem 8144 — 7y
0
I do have some code. Let me post it Objectly 49 — 7y
View all comments (3 more)
0
Posted. Objectly 49 — 7y
0
It seems I don't even need to find the average distance. I just need to know how to handle the zoom. Objectly 49 — 7y
1
Does this still need answering? nicemike40 486 — 7y

1 answer

Log in to vote
0
Answered by
TH669 0
7 years ago

Hey Objectly,

I don't completely understand this topic, though I do have some code that may help. This topic is called Camera Manipulation. You can find more information here: Wiki

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.

Ad

Answer this question