示例#1
0
    private void AnimationFollowEnemy(Vector2 position)
    {
        float x1 = position.x;
        float y1 = position.y;
        float x0 = gameObject.transform.position.x;
        float y0 = gameObject.transform.position.y;

        float angle = GetRotateAngleGameObject(x0, y0, x1, y1);

        if (angle < ANGLE_SWAP_STATE)
        {
            if (y0 < y1)
            {
                dwaft.AnimationMoveBeHind();
            }
            else
            {
                dwaft.AnimationMoveBefore();
            }
        }
        else if (angle >= ANGLE_SWAP_STATE)
        {
            dwaft.AnimationMoveLR();

            if (transform.position.x < position.x)
            {
                Vector2 scale = transform.localScale;
                scale.x = -1f;
                transform.localScale = scale;
            }
            else
            {
                Vector2 scale = transform.localScale;
                scale.x = 1f;
                transform.localScale = scale;
            }
        }
    }