SceneInstantiated AI enemy, runtime logic help

Options
Hi, I was wondering what happens if you spawn an AI enemy via PhotonNetwork.InstantiateSceneObject? I have tried looking around for the answer, but to no avail.

Does all of the attached scripts run on all of the clients, or does the scripts only run on the Master Client?

Comments

  • Hi @ivanhlb,

    the attached scripts are running on all clients. To limit this behaviour you can use a reference to the attached PhotonView component and check its isMine condition before doing something with the object, for example at the beginning of the Update function. See the easy example below:
    public void Update()
    {
        if (!pView.isMine)
        {
            return;
        }
    
        // This code only gets processed on the client who is the owner of the object.
        // If this is a scene object, the MasterClient is the owner and furthermore have the control.
    }