示例#1
0
文件: Ball.cs 项目: joouur/3DPONG
        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;
        }
示例#2
0
文件: Ball.cs 项目: cpthappy/3DPONG
        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;
        }