Exemplo n.º 1
0
    public void CatchBall(Ball ball)
    {
        if (ball == null)
        {
            return;
        }

        _heldBall = ball.GetComponentInParent <Rigidbody2D>();

        if (HoldingBall)
        {
            _heldBall.GetComponentInChildren <TrailRenderer>().emitting = false;
            ball.ResetSpeed();
            _heldBall.simulated   = false;
            _heldBall.isKinematic = true;

            _heldBall.transform.position = _holdPosition.position;
            _heldBall.transform.SetParent(_holdPosition);
            var paddle = GetComponentInParent <PaddleController>();
            _scoreKeeper.CaughtBall(paddle);

            ball.HitByPaddle(paddle);
        }
    }