Hey guys, I am trying to get a peace of code to work. The problem with converting from Unity Network to Photon is that for some reason I get an error when trying to call the photonView from the last player variable because its a GameObject (which works over networkView, the normal unity networking). I’ll list both scripts, one from the Photon and one from the Unity MasterServer, because I think that might help. Any help is appreciated, thank you in advance!
Unity MasterServer (works):
[RPC]
public void Client_PlayerJoined(string Username, NetworkPlayer id)
{
Player temp = new Player();
temp.PlayerName = Username;
temp.OnlinePlayer = id;
PlayerList.Add(temp);
if(Network.player == id)
{
MyPlayer = temp;
GameObject LastPlayer = Network.Instantiate(SpawnPlayer, Vector3.zero, Quaternion.identity, 0) as GameObject;
LastPlayer.networkView.RPC("RequestPlayer", RPCMode.AllBuffered, Username);
temp.Manager = LastPlayer.GetComponent<UserPlayer>();
Debug.Log("Spawned Player");
}
}
PhotonCloud Version (Error: Type UnityEngine.GameObject' does not contain a definition for photonView’ and no extension method photonView' of type UnityEngine.GameObject’ could be found (are you missing a using directive or an assembly reference?))
[RPC]
public void Client_PlayerJoined(string Username, PhotonPlayer id)
{
Player temp = new Player();
temp.PlayerName = Username;
temp.OnlinePlayer = id;
PlayerList.Add(temp);
if(PhotonNetwork.player == id)
{
MyPlayer = temp;
GameObject LastPlayer = PhotonNetwork.Instantiate("RigidBodyPlayer", Vector3.zero, Quaternion.identity, 0) as GameObject;
LastPlayer.photonView.RPC("RequestPlayer", PhotonTargets.AllBuffered, Username);
temp.Manager = LastPlayer.GetComponent<UserPlayer>();
MyPlayer.PlayerName.photonView.RPC("RequestPlayer", PhotonTargets.AllBuffered, Username);
Debug.Log("Spawned Player");
}
}
No ideas at all?
– Borzi