Multiplayer Multiple Camera

Hello I’m currently trying to create a top down 2-d game with two players. On game start each player is assigned to a camera, however I’m currently struggling to think of a way to implement this. If you guys have any advice it would be much appreciated. Thanks!

Hi @Jacob_Esswein and welcome,

If it’s a 2-players game with each player getting assigned a specific camera, what I’d do is as soon as the session starts and each player is assigned his camera then I’d disable the other one.

This way a single camera will be rendered for each player. If you plan to have each turn execute and rendered from the player’s perspective you can then swap the active camera with the opponent’s camera when the time comes.

Hello @Jacob_Esswein! You may be able to change the viewport of the cameras if you want to play the game split screen with both cameras on their own half of the screen. Then you can have one camera follow player one and the other camera follow player two.

1 Like

@Leonidas So I don’t think I gave enough information in my initial post, but in my game I play to make it multiplayer from two different browsers and each user will have different ‘tools’ in front of them, think something like “Keep Talking and Nobody Explodes” where one user has to give instructions to another user but both users have something different on screen so I am not sure that your implementation would work. Thanks though.

@Albertos Thank you for the feed back, what I was trying to do was create a multiplayer game where two people would get on from their browser and see two different interfaces, think “Keep Talking and Nobody Explodes”, would this be capable using viewports?

So, if both users are on different devices then you need to start working on a networking layer. How to exchange messages between the two users, a good example is the following tutorial:

That is a bit more complicated to realize. I did not know about that tutorial, so in the distant future I will also study it. Thanks @Leonidas and good luck @Jacob_Esswein!

in that tutorials can random people just open it and connect to the game and play with you? ive always wondered

Yes, right now random people can connect and play with you.

It’s up to you to decide if that’s desirable, otherwise you should implement an auth wall. So players have to login and get authorized before connecting to an active session.