/// <summary>
 /// Update the object's position according to speed and strategy
 /// </summary>
 private void UpdatePosition()
 {
     if (transform.childCount > 0)
     {
         if (!isPrefabLoaded)
         {
             isPrefabLoaded = true;
             PositionModifier pm = GetComponentInChildren <PositionModifier>();
             if (pm != null)
             {
                 forwardDirection = pm.ForwardDirection;
             }
         }
         if (isMoving)
         {
             //Should the speed change randomly
             if (RandomSpeed)
             {
                 speedResetTime += Time.deltaTime;
                 if (speedResetTime > SpeedChangeInterval)
                 {
                     speedResetTime = 0;
                     //Pick a random speed
                     ImSpeed = UnityEngine.Random.Range(Speed * 0.2f, Speed);
                 }
             }
             Strategy.UpdateMovement();
         }
     }
 }
        public override void OnAwake()
        {
            var animator = Owner.transform.GetChild(0).GetComponent <Animator>();

            animatorModifier = new AnimatorTriggerModifier()
            {
                Animator = animator,
                Name     = "Walk"
            };

            positionModifier = new PositionModifier()
            {
                Transform = transform,
            };
        }
        public virtual void Modify(GameObject source, GameObject target, GameObject offset = null)
        {
            if (!ValidateCache(source, target, offset))
            {
                return;
            }

            Premodified?.Invoke(eventData.Set(source, target, offset));

            if (ScaleModifier != null)
            {
                ScaleModifier.Modify(source, target, offset);
            }
            if (RotationModifier != null)
            {
                RotationModifier.Modify(source, target, offset);
            }
            if (PositionModifier != null)
            {
                PositionModifier.Modify(source, target, offset);
            }

            Modified?.Invoke(eventData.Set(source, target, offset));
        }