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

Is my logic correct for making a camera encompassing all the players at once?

Asked by 6 years ago

So, im trying to make a camera that will show all the players at once.

Say for example, all the players are spread out, the camera will try to accomadate for that.

BTW this is a 2-d style game

I haven't made it yet, but im thinking that a script should find the average of the x and y coordinates of all player humanoidrootparts, then set the camera to that average point.

But im still not sure how to determine the z coordinate.

I could keep it sationary and far so that i wont have to worry about the camera being too close in some occations, but i would preffer my camera to zoom in and out when players are close together and far away respectively.

is there any way to help determine the z axis, and is my logic for the x and y coordinates right?

thanks in advance.

1 answer

Log in to vote
0
Answered by
CodeLad 31
6 years ago

I believe a better way to do this is to get all of the player's distance from the center of the map, player, or whatever you're basing it from and have a function that returns the furthest player's position and distance. Then based on the distance you can set the camera offset. Getting averages and etc won't matter since you just need the furthest one to base it off of.

Ad

Answer this question