I’m trying to understand how to create a basic networking setup for a game that works like this:
Game is 1v1
One of the players is the host
Player 1 controls an FPS character. Player 2 needs to see the FPS character of Player 1.
Player 2 does not control an FPS character - he manages other stuff in the game (so no playerPrefab for Player 2).
Both players see the same level (so there can be an Online Scene for the NetworkManager).
So how do I set this up, so that when a game is started and both players connect, Player 1 starts controlling his character, and Player 2 sees Player’s 1 character ?
I don’t need details like how transform synchronization works just how to setup the Network Manager for this to work…
I thought you wanted the 1vs1 part to be automated, and in the automatic matchmaking atm has some issues.
If you can manually decide who hosts and who joins, then it shouldn’t concern you for now. http://wiki.unity3d.com/index.php/UNET#
Watch the Unite video with tanks example if you have time. But basically You create a prefab that every player will have, for simple controls you can add the standard FPS controller. Then every prefab that is synced has to have NetworkId, and if you want to sync the transform, you add the NetworkTransform component and adjust it for your needs. Then on some empty GameObject add a network manager and putt the required prefabs in the fields and that should be about it. When I start working on gameplay in my own project, I can bring more specific details. I hope this helps.
So yeah I understand the simple case, and that NetworkManager was probably made just for the simplest possible case… But that’s not exactly what I’m trying to do. Only one player has a prefab - the other doesn’t. Do you know how can I spawn the first player in both clients but not spawn anything for the second player?
I’m still learning networking but maybe add some code to the prefab in the start like
find prefab, if null then that’s player.
Else set the model for the prefab setactive to false. Set a bool is co player to true.
Then in update if player then goto this function.
if co player run this function.