0
\$\begingroup\$

I am currently into a 2d mobile multiplayer project. Its going to be a 2 player game for now. So the host and the client are the only players.

I am using Unity 5.4 and the default multiplayer platform by the way. I am able to spawn the character both on client and server. The syncing also works pretty well.

But for the game to be user friendly, obviously I have to spawn the player on his end of the screen and the opponent on the other end. I am unable to achieve this on the client screen. In the client screen, the client starts from the upper end of the screen making it difficult to play with.

So, my question. How would I go about spawning a player in his device on his end of the screen and the opponent on the other side? The only idea I came up with was switching the spawn points in the client version of the game. Is it possible accessing client's version of the game during runtime? And would it be the right way to go about it? If not please share an alternate solution.

Thanks

\$\endgroup\$
0
\$\begingroup\$

Shouldn't both players be treated like "clients"?

Even if one of the players is the host, the server should still be separated from the host's client, so the server would assign spawn points based on the player number (player 1 or 2, instead of 'me' and 'other player')

\$\endgroup\$
  • \$\begingroup\$ That is exactly the problem which I am facing. Like you said it spawns them based on player no. While this is good, the host has his player on his end of the screen(bottom end of his screen) and the opponent client on the other end(top end of his screen). The problem is, these same positions are used in the client mobile who is joining the game. It means the client who joins will have to play from the other end in his mobile. What I want is both the players to start from their end(bottom end of screen) in their respective mobiles while being displayed at the other end in the opponent's mobile. \$\endgroup\$ – Gabriel Aug 31 '16 at 11:07
  • \$\begingroup\$ oooh, idk if i understood correct, but does this mean that as the game works now, player 2 will see himself on the top of the screen? Sounds like you should maybe flip the viewport or rotate it somehow based on player nº \$\endgroup\$ – Brian H. Aug 31 '16 at 11:34
  • \$\begingroup\$ Yeah, but how do I do that without affecting how its being displayed in player 1's screen? In other words, I want to affect just the player2's screen. How do i do that? \$\endgroup\$ – Gabriel Aug 31 '16 at 11:40
  • \$\begingroup\$ since every client has only one player associated to it, you need a function that will return exactly that, so that you can call it to decide if you need to flip the viewport or not, when you manage to flip the view, you will also need to flip controls probably. :/ \$\endgroup\$ – Brian H. Aug 31 '16 at 12:41
  • \$\begingroup\$ I did think of it. It won't work as the viewport is a common thing for both players as both players rely on the same camera. A work around was to make the ground plane(play area) a spawnable object and spawn it with 180 rotation in the player 2 screen. But this will have no effect as spawn points still remain in the same area. I could make them children of the ground plane, so they flip along. But I feel this will add up to the complexity. If there is no alternative, i will have to either follow this method or maybe use another camera specifically for client. \$\endgroup\$ – Gabriel Aug 31 '16 at 13:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.