コード例 #1
0
 void FixedUpdate()
 {
     if (character.AttackContactWillLand())
     {
         character.AttackContact();
     }
     else
     {
         if (lastUpdateTime + updateRate + updateOffset < Time.time)
         {
             Transform closestTarget = character.GetClosestTargetTransformInVisionRange();
             if (closestTarget != null)
             {
                 target = closestTarget;
             }
             lastUpdateTime = Time.time;
         }
         if (target == null)
         {
             GetRandomTarget();
         }
         if (target != null)
         {
             character.MoveToPosition(target.position);
         }
     }
 }
コード例 #2
0
    void FixedUpdate()
    {
        Transform target = character.GetClosestTargetTransformInVisionRange();

        if (target != null)
        {
            character.ShootAt(target.position);
        }
    }