How to make the camera show all players?

I want the camera to zoom out when players go out of the camera’s reach, Kinda like super smash bros I think. Thanks!

1 Like

@ManiacPumpkin You may know how to do this.

You can use the Camera’s zoom input and I think if the value is smaller than 100, it starts to upscale the camera’s view to a larger area.

You could just take the distance between both players and when it starts to exceed a specific number, it’ll zoom out the camera.

If it’s a platformer, I would recommend only using the player’s X positions instead of including Y because in Smash Bros, when you fly in the air, the camera doesn’t track you other than a marker.

1 Like

Wait a while, I know how to do this, I’ll make an example game real quick.

2 Likes

Good idea, but I don’t know how to do this.

Okay, cool!

Do you want 2 players, or 3+

1 Like

it’s just Math.abs(x1 - x2) for x distance then filter it to see if the camera needs to zoom out or not

5 Likes

The game will be optional of how many players. The options are: 2 players, 3 players and 4 players.

1 Like

Alright, I’m making it rn

1 Like

Cool, thanks so much! Thank for your help @Galactian and thank you for your help @ManiacPumpkin.

1 Like

Sorry for the wait, my brain was not working. :sweat_smile:

But finally, here:
https://flowlab.io/game/view/2372804

It will find the min x, max x, min y, max y, of all your players. So if you need more / less players, just take out a couple variables. Also the C variable is the screen width. You’ll see the comment on the expression, just change the value of C to the width + hight of the screen

1 Like

Okay thanks! I’ll try it out.

Alright! It works. Please don’t delete this example though. I might still need it AND other people might also need it.

1 Like

Can you make it so that when all the players are close the camera doesn’t zoom in too far? Because it zooms in way to much when all the players are close.

Yeah, and actually it’s not perfectly how I want it, I’ll change it in a while, but now I gtg

Ok, I’ll make a zoom limit for each

1 Like

Oh okay, Bye!

1 Like

Nice.

You can just use filters yourself

1 Like

Unfortunately I don’t know where to put the filters.

1 Like