Hello
i am instantiating object when server add player
it is working perfect for every object on the network
and local player is working well
but
when switching the scene the client object doesn’t respond to local player condition
so how to solve this problem ! ? and how to save locality for the client object
I think part of the problem might be how scene change work in the HLAPI. It doesn’t move objects to a different scenes. It destroys them and recreates them.
unfortunately
No , Because i am using Don’t destroy on load in the network manager script
so the object that has been instantiated never destroyed and gone
and locality is working on server
but on client side No at all
public override void OnServerAddPlayer(NetworkConnection conn, short playerControllerId) // this method for detecting when new client join the room
{
Player_Creation++; // increase the integer for every client connected
if (Player_Creation == 1 ) // this to control the Host (The First Player who join )
{
// Select_player.enabled = false;
player_host = (GameObject)GameObject.Instantiate(wifi_player, spawnpoint.transform.position, Quaternion.identity); // instantiate the host in specific location
NetworkServer.AddPlayerForConnection(conn, player_host, playerControllerId);
Select_player.enabled = false;
//var go = GameObject. Instantiate(wifi_player) as GameObject;
// go.transform.parent = player.transform;
// player.transform.tag = "Player1"; // Give specific tag to the player
}
if (Player_Creation == 2) // This to control the Client (the secound player who join )
{
// Select_player.enabled = true;
// Client_join = true;
//Canvas_host_client = (GameObject)GameObject.Instantiate(playerPrefab, transform.position, Quaternion.identity); // instantiate the client in specific location
//NetworkServer.AddPlayerForConnection(conn, Canvas_host_client, playerControllerId);
player_client = (GameObject)GameObject.Instantiate(wifi_player,spawnpoint2. transform.position, Quaternion.identity); // instantiate the client in specific location
NetworkServer.AddPlayerForConnection(conn, player_client, playerControllerId);
Select_player.enabled = false;
// player.transform.tag = "Player2"; // Give specific tag to the player
}
}