MasterClient left, what now?

Options
Hi,

I'm making a game that has AI guards and player needs to escape them.

When the game starts the player who happens to be the MasterClient makes scene object instanses of the guards.

public override void OnJoinedRoom()
{

	if (PhotonNetwork.isMasterClient)
	{

	GameObject guard = PhotonNetwork.InstantiateSceneObject("BasicGuard", GuardPlace1.position, Quaternion.identity, 0, null);
	guard.GetComponent<DumbAndDumber>().ThisIsTheMaster();
	guard.name = "GuardOne";

	GameObject guard2 = PhotonNetwork.InstantiateSceneObject("BasicGuard", GuardPlace2.position, Quaternion.identity, 0, null);
	guard2 .GetComponent<DumbAndDumber>().ThisIsTheMaster();
	guard2 .name = "GuardTwo";

	}

}
This makes instances of guards that have AI components like this:

MasterClient Guard components:


Other players who are not the MasterClient have only components that will move the guard with Photon. My script deletes all the other scripts so they are just mesh with collider.

Other player Guard components:


So far this works. But my problem is that when the player who is the MasterClient leaves all the guards "lose their brain" and stop.

How do I move forward from here? Or am I doing this all wrong to begin with?

Thanks!

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Kapteeni,

    Thank you for choosing Photon!

    Please read more about "MasterClient and Host Migration".

    I'm not a PUN expert but I think you could transfer ownership (of AI objects) from the previous MasterClient to the new one.
  • Kapteeni
    Options
    JohnTube said:

    Hi @Kapteeni,

    Thank you for choosing Photon!

    Please read more about "MasterClient and Host Migration".

    I'm not a PUN expert but I think you could transfer ownership (of AI objects) from the previous MasterClient to the new one.

    Thank you! This was very helpful. I think I got it working by using this method.