I have a short question about making my Game a MultiplayerGame.
First a short summary. I develop a sportsgame where the player can use different characters for his team.
I did the tutorial and read the documentation about the HighLevel-API and i think i have a good overview of the topic.But as i wanted to start converting the Monobehaviours in Network-Behaviours there where immediate questionmarks.
The NetworkManager allows to link a single prefab which can be spawned automatically. In my case i want to spawn a team of different Characters which are configured in the GameMenu (eg 3on3) for each Player. In my SinglePlayerVersion my Gamelogic-Script reads the chosen Config and instantiates the whole Team accordingly. So now the questionmarks arose… As i obviously don’t wan’t to make a premade prefab for every config there is how do i approach this? Is it possible to do this with the high-level-api or do i have to move one Layer down the Unity-Rabbithole?
Can someone give me a hint how to do this? Basically my playerPrefab would be a gameobject with a TeamConfig-Script which would have to be configured before the game starts and an inputscript. Another way that i could think of after reading the HighLevelApi would be to use a Command to send the config to the server.
As there are two teams with multiple avatars spawned in the game the gamescript has to handle the positioning so the position-feature of the networkmanager as is is also not usable for me. (i think)
As I began extend the networkmanager i read some treads about the overrides which are called during the lifecycle but in conjunction with the questionmarks mentioned above there where even more questionmarks.
So before i continue i wanted to try if someone could share some inside with me.
I use the spawned player in the network manager as my networking dumping ground, but it’s not actually a player. It doesn’t appear on screen, so it doesn’t matter where it spawns. It contains all the commands and such, but player objects are a different class. You can spawn your players as you normally would, spawn them on the network with NetworkServer.Spawn and then add authority to them with AddClientAuthority (or even set them as UNET Player objects, although I wouldn’t recommend that. Authority is just as good, and it’s revocable. A player can’t have that status removed. You can only destroy the object.) Syncvars are a very easy way to then configure the player objects. I set one value that tells them which configuration values to look up from resources. That saves me having to send all the configurable data over the network. You can also use a variety of HLAPI methods to just send JSON (or whatever) back and forth to do your configuration.
So if i understand you correctly the networkplayer-object should contain all Commands which can be send to the server but nothing else? The actual GameObject which handles the whole team (config,input,etc) the local player Instantiates/configures and then spawn it over the the network?
Can i ask you a simple followup-Question? it might sound very simple but then for me it is still tricky.
I have a map-script attached to a gameobject which is queried for different information when a player moves (eg. is there an enemy on the next field etc, state of the next field etc.) This data can be obviously modified by both players. So if i understand correctly Syncvars are the way to go. Do i just syncvar the whole array?
Syncvars are one-way communication from the game server/host. Your players can send commands to the server/host which will then modify your array and the syncvar attribute cause that to be updated on the clients.