Exemple #1
0
 public void Move(float distance)
 {
     if (path != null)
     {
         Vector3 direction = path.transform.position - transform.position;
         if (direction.magnitude < distance)
         {
             if (trap != null)
             {
                 trap.EnterPath(this, path);
             }
             transform.position = path.transform.position;
             pathIndex++;
             SetPath();
             Move(distance - direction.magnitude);
         }
         else
         {
             transform.Translate(direction.normalized * distance);
         }
     }
 }