OnTriggerEnter not working at Unity3D

Viewed 13316

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 enter image description here

enter image description here

3 Answers

I have been through the same problem, I was trying to shoot an enemy with an arrow, but the arrow OnTriggerEnter(Collider collider) was not called at beginning, I enabled is Trigger in the enemy (the body I am trying to call the method on) this finally fixed my problem.

Related