UNET Unity Project - The second connected client does not seem to be created properly

I have been struggling with this for a couple of days. My goals were for each registered player to be assigned a role in managing the overall GameObject. (In this case, the reservoir). I reassigned NetworkManager with the following scripts: ( https://github.com/ChargerIIC/TankPrototype/blob/master/Assets/Scripts/Player/PlayerManager.cs ) ( https://github.com/ChargerIIC/TankPrototype/blob/master /Assets/Scripts/Player/PlayerInstance.cs ).

In the first instance of the application (host), the code works fine. The player selects the host, and the user is assigned the role of the "driver", is attached to the desired location and receives the correct input controller. The second instance of the application connects as a client and seems to appear without looking at the OnServerAddPlayer code - instead, the instance of this player’s object in the hosting application seems to receive the code that was launched and applied.

As an example, I have a couple of screenshots of this in action. In this case, my unity debugger is the first instance of the application (host), and I use the built-in exe as a clientAs a local host

All objects seem to appear incorrectly, and the second player is placed in the right place in the hierarchy. Annoyingly, the local host player now has input controllers, and simultaneously controls both positions.

In this screenshot, I used the compiled .exe for the host, and the debugger is connected as a local client: As a local client

Here, game objects do not have a place in the hierarchy set and do not have the necessary controllers. The second player cannot see the general object (tank) or even interact with it.

I am new to UNET, and I'm sure something is missing, but after I dug up unity documents, I couldn’t understand that. Does anyone know what I can do wrong or what I can check next?

+4
source share

Source: https://habr.com/ru/post/1664582/


All Articles