Ejemplo n.º 1
0
    private void OnCollisionEnter(Collision other)
    {
        ContactPoint hitAngle = other.contacts[0];      // get point of contact with other object

        ReflectBounce(hitAngle.normal);                 // change forward direction
        if (other.gameObject.CompareTag("Bottom Sensor"))
        {
            if (isColliding || bottomSensorBounce)
            {
                return;
            }
            else
            {
                isColliding = true;     // prevent multiple registers of the collision as it passes through the sensor
            }
            levelController.ballCount--;
            if (player.GetComponent <PlayerController>().isAgent)
            {
                player.GetComponent <AgentController>().LostBall();
            }
            Destroy(gameObject);
        }
        else if (other.gameObject.CompareTag("Player"))
        {
            sfx.PlayPaddleHit();
        }
    }