Ejemplo n.º 1
0
    private void Update()
    {
        //if the target for some reason was destroyed, destroy missle
        if (target == null)
        {
            Destroy(gameObject); return;
        }

        if (isReady)
        {
            //if the target has moved from the previous coordinate(targetOldPos) to more than "targetPathUpdateOffset", update the path to the target
            if (Vector3.Distance(targetOldPos, target.position) > targetPathUpdateOffset)
            {
                targetOldPos = target.position;
                if (thisPursuerInstance.GetCurCondition() == "Movement")
                {
                    thisPursuerInstance.RefinePath(target);
                }
                else
                {
                    thisPursuerInstance.MoveTo(target, true);
                }
            }
        }
    }
Ejemplo n.º 2
0
 public void Move(Vector3 targetPosition)
 {
     //if the target has moved from the previous coordinate(targetOldPos) to more than "targetPathUpdateOffset", update the path to the target
     if ((_targetOldPosition - targetPosition).sqrMagnitude > _targetPathUpdateOffset * _targetPathUpdateOffset)
     {
         _targetOldPosition = targetPosition;
         if (_pursuer.GetCurCondition() == "Movement")
         {
             _pursuer.RefinePath(targetPosition + Vector3.up * 3f);
         }
         else
         {
             _pursuer.MoveTo(targetPosition + Vector3.up * 3f, true);
         }
     }
 }