示例#1
0
        public void Configure()
        {
            Translator = TranslateSelf ? transform : transform.GetChild(0);
            Scaler     = Translator.GetChild(0);
            Rotator    = Scaler.GetChild(0);

            if (Rotator.childCount > 0)
            {
                Subject = Rotator.GetChild(0);
            }
            if (OptionalPrefab)
            {
                if (Subject != null)
                {
                    DestroyImmediate(Subject.gameObject);
                }
                Subject = Instantiate(OptionalPrefab, Rotator).transform;
                Subject.transform.localPosition = Vector3.zero;
                Subject.transform.localRotation = Quaternion.identity;
                Subject.transform.localScale    = Vector3.one;
            }
        }
示例#2
0
        void Awake()
        {
            if (Anim == null)
            {
                Anim = GetComponentInParent <Animator>();                //Cache the Animator
            }
            if (RB == null)
            {
                RB = GetComponentInParent <Rigidbody>();                 //Catche the Rigid Body
            }
            if (MainCamera == null)
            {
                MainCamera = MTools.FindMainCamera()?.transform;         //Find the Camera
            }
            if (Rotator != null && RootBone == null)
            {
                RootBone = Rotator.GetChild(0);           //Find the First Rotator Child  THIS CAUSE ISSUES WITH TIMELINE!!!!!!!!!!!!
            }
            GetHashIDs();

            foreach (var set in speedSets)
            {
                set.CurrentIndex = set.StartVerticalIndex;
            }

            if (RB)
            {
                RB.useGravity  = false;
                RB.constraints = RigidbodyConstraints.FreezeRotation;
            }

            GetAnimalColliders();

            for (int i = 0; i < states.Count; i++)
            {
                if (states[i] != null)
                {
                    if (CloneStates)
                    {
                        State instance = (State)ScriptableObject.CreateInstance(states[i].GetType());
                        instance      = ScriptableObject.Instantiate(states[i]);                            //Create a clone from the Original Scriptable Objects! IMPORTANT
                        instance.name = instance.name.Replace("(Clone)", "(C)");
                        states[i]     = instance;
                    }

                    //statesD.Add(states[i].ID.ID, states[i]);        //Convert it to a Dictionary

                    states[i].SetAnimal(this);                                          //Awake all States
                    states[i].Priority = states.Count - i;
                    states[i].AwakeState();
                }
            }



            //Awake all modes
            for (int i = 0; i < modes.Count; i++)
            {
                modes[i].Priority = modes.Count - i;
                modes[i].AwakeMode(this);
            }

            SetPivots();
            CalculateHeight();

            currentSpeedSet = new MSpeedSet()
            {
                Speeds = new List <MSpeed>(1)
                {
                    new MSpeed("Default", 1, 4, 4)
                }
            };                                                                                                     //Create a Default Speed at Awake


            AlignUniqueID = UnityEngine.Random.Range(0, 99999);
        }