예제 #1
0
파일: Game.cs 프로젝트: dzil123/Unity-Pong
    public void HitPaddle(bool side)
    {
        // Because the paddle is 1 length long, this float is -1.0 < x < 1.0
        // Is paddle != 1 length long, then correct to get in range

        //Debug.Log(side.ToString());

        float y_offset = m_paddles.GetYOffset(side, m_ball.transform.position);

        float angle = m_middle_angle;

        angle += m_range_angle * y_offset * -1f;

        angle = Mathf.Clamp(angle, 1f, 179f);         // stops wildly random angles

        if (side)
        {
            angle *= -1f;
        }

        //Debug.Log(y_offset.ToString());
        //Debug.Log(angle_spread.ToString());
        //Debug.Log(angle.ToString());

        m_ball.ChangeRotation(angle, m_ball.m_speed);
    }