Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Child collider not triggering after setActive true

Discussion in '2D' started by Ronni_Boni, Dec 28, 2022.

  1. Ronni_Boni

    Ronni_Boni

    Joined:
    Dec 19, 2022
    Posts:
    4
    Hi currently I have a trigger circle collider in a child of my player that becomes active after pressing a key before going back to sleep and it is supposed to detect triggers from other gameObjects with boxcolliders and Rigidbodies in it but it does not seem to be working. The code I have right now is to let me know if it got triggered which it doesnt.

    public class Inpulse : MonoBehaviour
    {
    CircleCollider2D ObjectCollider;

    private void OnTriggerEnter(Collider other)
    {
    print ("Inpulse");
    }

    // Start is called before the first frame update

    // Update is called once per frame
    void Update()
    {

    }

    void Awake()
    {
    ObjectCollider = GetComponent<CircleCollider2D>();
    }
    }
     
  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,621
    You're using the 3D physics callback, not the 2D physics callback. It's OnTriggerEnter2D.

    Also, please use code-tags when posting code.

    Thanks.
     
    Ronni_Boni likes this.
  3. Ronni_Boni

    Ronni_Boni

    Joined:
    Dec 19, 2022
    Posts:
    4
    o I see thank you so much!