3
\$\begingroup\$

Im very new to Networking in Unity 5. Im trying to bring the finished basis for my 2 player, 1 vs 1, turn-based game I made for local multiplayer (both players on same computer) to an online matchmaking system.

In the game currently (for local), there are 3 cameras. 2 centered on separate canvases for selecting attacks for each player.

that once p1 chooses his attacks and presses continue, the camera is deactivated and the 2nd camera for p2's attacks is activated. Once p2 presses to continue the 2nd cam is also deactivated

and the 3rd cam is put on, this camera is set on the battle arena and plays out in turns the moves picked by the 2 players through a turn-determining system.

What I want to do for the online is have both canvas cameras activated at the same time and each player to be assigned to a different camera. So is there a good way i should do this? NetworkView on one of the cams? Hope I explained the premise enough :P

\$\endgroup\$
1
\$\begingroup\$

That's not how your online game will work. When playing on separate computers, you'll still only have one camera active at a time. There will be two instances of the game being run, clients A and B. A will have camera 1 active, B will have camera 2 active. The rest of the game world is synced between the clients.

It will be a lot of work to retrofit your local multiplayer game for online multiplayer if it's not designed for it.

\$\endgroup\$
  • \$\begingroup\$ Thanks for the feedback. How can I assign the cameras though for each player. Can I differentiate which player is which depending on who is the host and assign cameras based on that? \$\endgroup\$ – Remember The BBQ Jul 19 '16 at 21:33
  • \$\begingroup\$ You can assign them based on host, or who clicks start first, or random number, up to you. \$\endgroup\$ – MichaelHouse Jul 19 '16 at 22:24
  • \$\begingroup\$ I am using the Unity networking as I just want it to be a small scale neat project. Can I essentially make a lobby where you can either be a host and wait for someone to join and if you want to join a certain room you'll just see it in the open lobbies, deciding which player takes what side (p1 canvas and cam, or p2's) depending on who started the new lobby as p1 and the one who joins is p2? \$\endgroup\$ – Remember The BBQ Jul 20 '16 at 17:30
  • \$\begingroup\$ Yes, that's certainly possible using Unity Networking. \$\endgroup\$ – MichaelHouse Jul 20 '16 at 17:39
  • \$\begingroup\$ Once I have the whole lobby situation complete, and I assign each player a different view to their respective cam and canvas. What parts are needed to be synced? I know already that I'll need to sync the bool value for both players if they pressed "Continue" to play out their choices, and I'll need a Network Transform on each player sprite to sync out their movement and attacks, but what other things should be synced with a syncvar or some other type of syncing? the health values of each player, the string values of what picks each player chose so they're synced before playing out the choices? \$\endgroup\$ – Remember The BBQ Jul 20 '16 at 17:54

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.