- Home /
Multiplayer prefab player fall through floor on instantiate
Hello Unity community, this will be my first post!
I have a problem with my multiplayer setup. When a client connects to the player-hosted server they both fall through the floor... its not a collider issue - The server-player can walk around fine untill a client-player connects; then they both fall through the ground.
Firstly let me explain my network scripts:
I have two scripts 'NET_Server.cs' and 'NET_Client.cs' There is an empty GameObject in the scene called "PlayerSpawn"
I have two separate builds of the game - one for client one for server.
When the server starts - the player who is hosting gets their prefab instantiated after the server calls the methods Network.InitializeServer() and MasterServer.RegisterHost(); all overloads are included and the init runs fine.
When a client starts the game and retrieves the server via the MasterServer host list the client connects. When the client connects OnConnectedToServer() gets called in NET_Client.cs and run the following
print ("[CLIENT] CONNECTED TO SERVER");
Network.Instantiate(playerPrefab,playerSpawn.position,Quaternion.identity,0);
The two overload vars are:
public Transform playerSpawn; public GameObject playerPrefab;
Now let me explain my NET_CheckOwnership script that runs in the instantiated prefab:
void Awake() {
if (!networkView.isMine) { playerObject.GetComponentInChildren().enabled = false; playerObject.GetComponentInChildren().enabled = false; playerObject.GetComponentInChildren().enabled = false; //playerObject.GetComponent().enabled = false; } else { playerObject.GetComponentInChildren().enabled = true; playerObject.GetComponentInChildren().enabled = true; playerObject.GetComponentInChildren().enabled = true; } }
please help, I've looked everywhere for someone suffering the same error with no luck. Is this problem because I am instantiating in the wrong place or at the wrong time? eek..