Hey, I have a problem with controlling my player in a room. So basically everything works fine until another player joins the room. If another player joins the game, everything is getting out of control, the weapon controller, plyer damage etc etc. I tried photonview.IsMine but if i do it won't even start the code because photonview is not mine. I tried to enable/disable the scripts on spawning, didn't work too. How can I prevent this control problem 100%?
Ok, here: Code (CSharp): [PunRPC] private void InitializeAllWeapons() { if (AreWeapons(PhotonNetwork.player)) { return; } // if weapons are already registered, get me out of here Debug.Log("player reguested weapon initializ: " + PhotonNetwork.playerName); // who requested weapons? for(int i=1; i < Slot.Length; i++) // loop trough weapons slots 1-4 { UnityItem unityItem; // weapon item contains all infos id, name, prefab if (LoadOutManager.TryGetWeaponItem(out unityItem, i)) // try to get item out loadoutmanager { Slot[i] = new WeaponSlot(i, unityItem, attach__, PhotonNetwork.player.ID); // set up slot Slot[i].InitializeWeaponItem(); // Initialize weapon RegisterWeapon((byte)i, Slot[i].WeaponID, PhotonNetwork.player.ID); // Register weapon } else { Debug.LogError(string.Format("Failed to initialize weapon slot: {0}", i)); //Debug.LogError("unityitem: " + unityItem.name); } } AddRequatedWeapons(PhotonNetwork.player); // tell all weapons were initialized, } weapon Initialize: Code (CSharp): public void InitializeWeaponItem() { Debug.Log("initializing weapons!"); ItemObject = PhotonNetwork.Instantiate(Item.name, Vector3.zero, Quaternion.identity, 0); //Load our weapon object from resourcess folder UnityItemManager.AttachWeaponItem(ItemObject, AttachPoint_.transform); // Attach our object as a child to any object ItemObject.transform.localPosition = UnityItemManager.SetUpWeaponHelperPosition(ItemObject.transform);//Set up the position of our weapon ItemObject.transform.localRotation = UnityItemManager.SetUpWeaponHelperRotation(ItemObject.transform);//Set up the rotation of our weapon }
So the problem is everything works fine by the 1st player but if another joins his weapons are invisible for the other clients.