예제 #1
0
 private void OnEnable()
 {
     if (EnemyPath.points == null)
     {
         return;
     }
     transform.position = EnemyPath.GetFirstPoint();
     target             = EnemyPath.GetNextPoint(0);
     currentPoint       = 1;
 }
예제 #2
0
    private void Update()
    {
        float   diff;
        Vector3 tmp = transform.position;

        transform.position = Vector3.MoveTowards(transform.position, target, dataHolder.data.Speed * Time.deltaTime);
        diff      = Vector3.Distance(tmp, transform.position);
        distance += diff;
        if (diff < float.Epsilon)
        {
            target = EnemyPath.GetNextPoint(currentPoint);
            currentPoint++;
        }
    }