예제 #1
0
 void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.tag == "Paddle")
     {
         float   x         = hitFactor(transform.position, other.transform.position, other.collider.bounds.size.x);
         Vector2 direction = new Vector2(x, 1).normalized;
         rigid2D.velocity = direction * speed;
     }
     else if (other.gameObject.tag == "Wall")
     {
         Vector2 newVelocity = Vector2.Reflect(rigid2D.velocity, other.contacts[0].normal);
         rigid2D.velocity = newVelocity;
     }
     else if (other.gameObject.tag == "Brick")
     {
         Vector2 newVelocity = Vector2.Reflect(rigid2D.velocity, other.contacts[0].normal);
         rigid2D.velocity = newVelocity;
     }
     else if (other.gameObject.tag == "GameOver")
     {
         highScoreController.GameOver();
     }
 }