Beispiel #1
0
 void MoveToTarget(Vector3 direction)
 {
     if (targetDistance > 70f && state != anglerfishState.biting)
     {
         rb.velocity = direction * speed;
     }
     else if (targetDistance <= 50f && state == anglerfishState.chasing)
     {
         rb.velocity = direction * speed / 5;
         state       = anglerfishState.biting;
         Damage();
     }
 }
Beispiel #2
0
    private void Update()
    {
        ChangeMusic();

        targetDistance = Vector3.Distance(target.position, transform.position);
        Vector3 direction = target.position - transform.position;

        direction.Normalize();
        movement = direction;

        switch (state)
        {
        case anglerfishState.chasing:
            LookAtTarget();
            print("chasing");
            break;

        case anglerfishState.biting:
            print("biting");
            //Application.Quit();
            state = anglerfishState.chasing;
            break;
        }
    }