I'm trying to detect a ball entering throw a ring in a basketball game. I am using the following script at the ring
public class Anotar : MonoBehaviour {
    private ControlJuego control;
    void Start(){
        GameObject gameControllerObject = GameObject.FindWithTag ("ControlJuego");
        if (gameControllerObject != null)
        {
            control = gameControllerObject.GetComponent <ControlJuego>();
        }
        if (control == null)
        {
            Debug.Log ("Cannot find 'GameController' script");
        }
    }
    void OnTriggerEnter (Collision col)
    {
        control.puntuar (2);
    }
    void OnCollisionEnter (Collision col)
    {
        //control.puntuar (3);
    }
}
The ring has a box collider set as trigger to detect the OnTriggerEnter method. It also has a mesh collider to detect when the ball touch it throw OnCollisionEnter. My problem is that OnTriggerEnter is not working (used breakpoint inside and it doesn't stop). Actually OnCollisionEnter works fine. My ball has a sphere collider and both use rigidbody. Any idea?
Edit: I attach screenshots from my ball and ring


void OnTriggerEnter (Collision col)
{
    control.puntuar (2);
}
this will never work. OnTriggerEnter needs a Collider not an Collision. Try this:
void OnTriggerEnter (Collider col)
{
    control.puntuar (2);
}
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With