How i should do it correctly?
Options
AmIDuck
✭
When I try to pick up the lamp, it appears in the player's hands who picked it up, but for other players, it just spawns at a point, and does not bind to the player.
Also i tried to comment first 2 lines of code in AddLamp method, and now there is 2 lamps on the map, so weird. Can you help me, please?
private void Update() { if(!photonView.IsMine && PhotonNetwork.IsConnected) return; if (Input.GetKeyDown(PICKUP) && _inRange && _item != null) photonView.RPC("TakeItem", RpcTarget.All); } [PunRPC] private void TakeItem() { if (!ItIsObject()) return; if (_item.CompareTag(_itemTags[3])) { if(_itemInventoryScript.haveMainItem) return; //photonView.RPC("AddLamp", RpcTarget.All); _itemInventoryScript.AddLamp(); } _audioSource.PlayOneShot(_pickUpSound); _triggerEnters--; Destroy(_item); }
[ANOTHER SCRIPT]
public void AddLamp() { if(!photonView.IsMine && PhotonNetwork.IsConnected) return; haveMainItem = true; GameObject lamp = PhotonNetwork.Instantiate(HANDITEMSPATH + _lampPrefab.name, _itemsPosition.position, Quaternion.identity); lamp.transform.parent = _itemsPosition; lamp.transform.localPosition = new Vector3(0f, 0.03f, 0.15f); lamp.transform.localRotation = Quaternion.Euler(-90, 0, 30); }
If do simple Instantiate(without PhotonNetwork) i can't get access to object, because IsMine always false
0