Keep the multiple players within the screen

I want to keep all players within the screen like in Enter the Gungeon but unfortunately I can’t achieve it. I use Centroid to find the center of the players and change the camera position to that point. Also I was trying to use Math.Clamp to set boundaries for players to stay inside camera view.

And now troubles start.

When one of the palyers approaches to this boundaries, it moves the camera and other players.

I have no idea what what to change to make it work.

Here’s what it should look like: Untitled - YouTube

This tutorial can helps you

Ah okay, I don’t know how to do that, maybe you can make 4 boxes (with collider) and make them child of the camera, then put them in the camera borders. I’m not sure if it will work but you can try :confused: