Exemplo n.º 1
0
        public void Awake()
        {
            BallRb = GetComponent<Rigidbody>();
            //BallRb.useGravity = false;
            //BallRb.AddRelativeForce(Vector3.one * 500);
            if (startSpeed == 0)
                startSpeed = -15.0f;
            BallRb.maxAngularVelocity = maxAngularSpeed;
            BallRb.AddRelativeTorque(Vector3.one);
            BallRb.velocity = new Vector3(0, startSpeed, 0);
            grav = new Vector3(0, -9.81f, 0);

            playerContact = GameObject.FindGameObjectWithTag("Player").GetComponent<PaddleContact>();
            enemyContact = GameObject.FindGameObjectWithTag("Enemy").GetComponent<PaddleContact>();

            playerContact.ball = this;
            enemyContact.ball = this;

            ballAudio = GetComponent<AudioSource>() as AudioSource;
        }
Exemplo n.º 2
0
        public void Awake()
        {
            BallRb = GetComponent <Rigidbody>();
            //BallRb.useGravity = false;
            //BallRb.AddRelativeForce(Vector3.one * 500);
            if (startSpeed == 0)
            {
                startSpeed = -15.0f;
            }
            BallRb.maxAngularVelocity = maxAngularSpeed;
            BallRb.AddRelativeTorque(Vector3.one);
            BallRb.velocity = new Vector3(0, startSpeed, 0);
            grav            = new Vector3(0, -9.81f, 0);

            playerContact = GameObject.FindGameObjectWithTag("Player").GetComponent <PaddleContact>();
            enemyContact  = GameObject.FindGameObjectWithTag("Enemy").GetComponent <PaddleContact>();

            playerContact.ball = this;
            enemyContact.ball  = this;

            ballAudio = GetComponent <AudioSource>() as AudioSource;
        }