Создать объект и сделать его дочерним. Photon Cloud

Сеть в Unity3D

Создать объект и сделать его дочерним. Photon Cloud

Сообщение VladikDEV 08 янв 2018, 02:10

Хочу реализовать подбор оружия (скрипт брал из уже готового оффлайн проекта).
Оружие на сцене уничтожается, по айдишнику создается его копия в руках игрока.
На данный момент игроки нормально видят оружие в своих руках, но не видят что в руках у противника. Если убрать строчку
Синтаксис:
Используется csharp
equipedObject.transform.parent = equipTransform_RPC;

то оружие создается нормально, но на сцене а не в руках игрока)
собственно подскажите пожалуйста как сделать его дочерним к руке игрока)
Вернее дочерним то оно становится, но тогда не отображается для других игроков.
Синтаксис:
Используется csharp
        private GameObject originalITEM;
        private Transform equipTransform_RPC;
        private GameObject equipedObject = null;
        [PunRPC]
        public void InstantiateWeapon(Vector3 pos, Quaternion rot)
        {
            for (int i = 0; i < resources_weapon.Length; i++)
                if (originalITEM.transform.name == resources_weapon[i].transform.name)
                {
                    equipedObject = PhotonNetwork.Instantiate(resources_weapon[i].transform.name, pos, rot, 0, null);
                    equipedObject.transform.parent = equipTransform_RPC;
                    break;
                }
        }
        IEnumerator EquipItemRoutine(EquipPoint equipPoint, vItem item)
        {
            Debug.Log("EquipItemRoutine(EquipPoint equipPoint, vItem item)");
            if (!inEquip)
            {
                inventory.canEquip = false;
                inEquip = true;
                if (!inventory.isOpen)
                {
                    while (equipTimer > 0)
                    {
                        equipTimer -= Time.deltaTime;
                        if (item == null) break;
                        yield return new WaitForEndOfFrame();
                    }
                }
                if (equipPoint != null)
                {
                    if (item.originalObject)
                    {
                        if (equipPoint.equipmentReference != null && equipPoint.equipmentReference.equipedObject != null)
                        {
                            var _equipment = equipPoint.equipmentReference.equipedObject.GetComponent<vIEquipment>();
                            if (_equipment != null) _equipment.OnUnequip(equipPoint.equipmentReference.item);
                            PhotonNetwork.Destroy(equipPoint.equipmentReference.equipedObject);
                        }

                        var point = equipPoint.handler.customHandlers.Find(p => p.name == item.customEquipPoint);
                        var equipTransform = point != null ? point : equipPoint.handler.defaultHandler;
                        originalITEM = item.originalObject;
                        equipTransform_RPC = equipTransform;
                        if (view.isMine)
                            view.RPC("InstantiateWeapon", PhotonTargets.All, equipTransform.position, equipTransform.rotation);

                        if (equipPoint.equipPointName.Contains("Left"))
                        {
                            var scale = equipedObject.transform.localScale;
                            scale.x *= -1;
                            equipedObject.transform.localScale = scale;
                        }

                        equipPoint.equipmentReference.item = item;
                        equipPoint.equipmentReference.equipedObject = equipedObject;
                        var equipment = equipedObject.GetComponent<vIEquipment>();
                        if (equipment != null) equipment.OnEquip(item);
                        equipPoint.onInstantiateEquiment.Invoke(equipedObject);
                    }
                    else if (equipPoint.equipmentReference != null && equipPoint.equipmentReference.equipedObject != null)
                    {
                        var _equipment = equipPoint.equipmentReference.equipedObject.GetComponent<vIEquipment>();
                        if (_equipment != null) _equipment.OnUnequip(equipPoint.equipmentReference.item);
                        PhotonNetwork.Destroy(equipPoint.equipmentReference.equipedObject);
                        equipPoint.equipmentReference.item = null;
                    }
                }
                inEquip = false;
                inventory.canEquip = true;
                if (equipPoint != null)
                    CheckTwoHandItem(equipPoint, item);
            }
        }
 
VladikDEV
UNIт
 
Сообщения: 88
Зарегистрирован: 24 май 2016, 13:45
Откуда: Минск

Re: Создать объект и сделать его дочерним. Photon Cloud

Сообщение VladikDEV 08 янв 2018, 18:24

Кто-нибудь?)
VladikDEV
UNIт
 
Сообщения: 88
Зарегистрирован: 24 май 2016, 13:45
Откуда: Минск

Re: Создать объект и сделать его дочерним. Photon Cloud

Сообщение VladikDEV 09 янв 2018, 22:14

решено
VladikDEV
UNIт
 
Сообщения: 88
Зарегистрирован: 24 май 2016, 13:45
Откуда: Минск


Вернуться в Сеть

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 4