Пример #1
0
    void Update()
    {
        if (enemy.inAction)
        {
            return;
        }

        else
        {
            flipTimer += Time.deltaTime;
            if (flipTimer >= flipCooldown)
            {
                enemy.LookAtTarget();
                flipTimer = 0;
            }

            int   dirX      = enemy.FacingRight ? 1 : -1;
            int   dirY      = enemy.PlayerDeltaY + 1.5 > 0 ? 1 : -1;
            float velocityX = dirX * speed;
            float velocityY = dirY * speed * 0.5f;

            if (this.WithinStopDistance())
            {
                velocityX = 0;
            }

            enemy.SetVelocityX(velocityX);
            enemy.SetVelocityY(velocityY);
        }
    }
Пример #2
0
    void Update()
    {
        if (enemy.inAction || this.WithinStopDistance())
        {
            enemy.SetSpeed(0);
        }
        else
        {
            flipTimer += Time.deltaTime;
            if (flipTimer >= flipCooldown)
            {
                enemy.LookAtTarget();
                flipTimer = 0;
            }

            enemy.SetSpeed(speed);
        }
    }