void Start()
        {
            m_Rigidbody.constraints   = RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ;
            m_OrigGroundCheckDistance = m_GroundCheckDistance;

            MainCamera = MalbersTools.FindMainCamera()?.transform;
        }
Exemple #2
0
        void OnEnable()
        {
            if (MainCamera == null)
            {
                MainCamera = MalbersTools.FindMainCamera()?.transform; //Find the Camera
            }
            if (Animals == null)
            {
                Animals = new List <MAnimal>();
            }
            Animals.Add(this);          //Save the the Animal on the current List

            GetInputs(true);

            foreach (var state in states)
            {
                state.ResetState();
            }

            if (isPlayer)
            {
                SetMainPlayer();
            }


            SetBoolParameter  += SetAnimParameter;
            SetIntParameter   += SetAnimParameter;
            SetFloatParameter += SetAnimParameter;
        }
        void Awake()
        {
            MainCamera = MalbersTools.FindMainCamera();

            graphic = GetComponent <Graphic>();

            ScreenCenter = transform.position;
        }
Exemple #4
0
        void Awake()
        {
            if (MainCamera == null)
            {
                MainCamera = MalbersTools.FindMainCamera().transform;
            }


            if (Anim == null)
            {
                Anim = GetComponentInParent <Animator>();                         //Cache the Animator
            }
            if (RB == null)
            {
                RB = GetComponentInParent <Rigidbody>();                        //Catche the Rigid Body
            }
            SpeedMultiplier = 1;
            GetHashIDs();
            OptionalAnimatorParameters();   //Enable Optional Animator Parameters on the Animator Controller;

            _transform = transform;         //Cache the Transform

            CurrentSpeedSet = new MSpeedSet()
            {
                Speeds = new List <MSpeed>(1)
                {
                    new MSpeed("Default", 1, 4, 4)
                }
            };

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

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

            GetAnimalColliders();

            //DefaultAnimatorUpdate = Anim.updateMode;//Cache the Update Mode on the Animator to Physics or Normal

            statesD = new Dictionary <int, State>();

            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;
                    }

                    if (states[i].Active)
                    {
                        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();
                }
            }

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


            InputSource = GetComponentInChildren <IInputSource>();      //Cache the Input Source

            SetPivots();
            CalculateHeight();

            HitDirection = Vector3.zero; //Reset the Damage Direction;
        }
Exemple #5
0
 private void OnEnable()
 {
     MainCamera = MalbersTools.FindMainCamera();
     Align();
 }