Photon View owner problem

Options
Hello

I have problem with photon view owner.

1st client joins, ship prefab is instantiated and everything works fine.



2nd client joins and now 2nd ship is controlled locally by 1st client application



I have owner set to fixed.

Here is my code for ship instatntiation on room join.
using UnityEngine;
using System.Collections;

public class OnJoinedInstantiate : Photon.PunBehaviour
{
    public GameObject[] PrefabsToInstantiate;   // set in inspector

	public override void OnJoinedRoom ()
	{
		if (this.PrefabsToInstantiate != null)
		{
			foreach (GameObject o in this.PrefabsToInstantiate) {
				Vector3 SpawnPosition = new Vector3 (0, 0, 300 * PhotonNetwork.room.PlayerCount);

				GameObject newPlayerPrefab = PhotonNetwork.Instantiate (o.name, SpawnPosition, Quaternion.identity, 0);
			}
		}
	}
}



Comments

  • [Deleted User]
    Options
    Hi @Elmah,

    please make sure that you have a photonView.isMine condition in your MoveBoatMultiplayer script to avoid the described scenario. Before handling any input add the following code snippet:
    if (!photonView.isMine)
    {
        return;
    }
  • Elmah
    Options
    Yes I am aware of isMine property but there is no need to use it in my case because input is handled by UI that is created for each player. The result is that one UI controls specific ship and it seems that every player can see proper UI for his ship but can't move it.
  • [Deleted User]
    Options
    Can you share some code how you are doing the input from UI? I guess there is something wrong because you told that the first player can also control the second player's ship. Another question about the UI: is it instantiated when the player joins the room or is this pre-build in the editor?