Пример #1
0
        private void SpawnObj(CharacterControl control)
        {
            if (control.ap.PoolObjectList.Contains(ObjectType))
            {
                return;
            }

            Debug.Log("Spawning " + ObjectType.ToString() + "|||||||||||||| Looking for: " + ParentObjectName);

            GameObject obj = PoolManager.Instance.GetObject(ObjectType);

            if (!string.IsNullOrEmpty(ParentObjectName))
            {
                GameObject p = control.GetChildObj(ParentObjectName);
                obj.transform.parent        = p.transform;
                obj.transform.localPosition = Vector3.zero;
                obj.transform.localRotation = Quaternion.identity;
            }

            if (!StickToParent)
            {
                obj.transform.parent = null;
            }

            obj.SetActive(true);

            control.ap.PoolObjectList.Add(ObjectType);
        }
Пример #2
0
        private void SpawnObj(CharacterControl control)
        {
            if (control.ap.PoolObjectList.Contains(ObjectType))
            {
                return;
            }

            Debug.Log("Spawning " + ObjectType.ToString() + "|||||||||||||| Looking for: " + ParentObjectName);

            GameObject obj = PoolManager.Instance.GetObject(ObjectType);

            if (!string.IsNullOrEmpty(ParentObjectName))
            {
                GameObject p;

                if (control.GetChildObj(ParentObjectName) == null)
                {
                    p = GameObject.Find(ParentObjectName);
                }
                p = control.GetChildObj(ParentObjectName);
                obj.transform.parent        = p.transform;
                obj.transform.localPosition = Vector3.zero;
                obj.transform.localRotation = Quaternion.identity;
            }

            if (Throwable)
            {
                Rigidbody rb = obj.GetComponent <Rigidbody>();
                obj.transform.localPosition = Vector3.zero;
                obj.transform.localRotation = Quaternion.identity;


                if (obj.transform.root.GetComponent <CharacterControl>().FaceLeft)
                {
                    rb.velocity = -Vector3.forward * Speed;
                }
                else
                {
                    rb.velocity = Vector3.forward * Speed;
                }
                obj.transform.parent = null;
            }

            if (Explosive)
            {
                obj.transform.parent = GameObject.Find(ExplosiveParent).transform;
            }

            if (!StickToParent)
            {
                obj.transform.localPosition = Vector3.zero;
                obj.transform.parent        = null;
                obj.transform.localRotation = Quaternion.identity;
            }

            if (OffsetRot)
            {
                obj.transform.rotation = rotation;
            }



            obj.SetActive(true);

            control.ap.PoolObjectList.Add(ObjectType);
        }