GetComponent<>() not finding a Collider

My Problem is some very wierd behaviour from Unity.
I have a Player Object with 3 Children each with their own Collider. Im trying to acces them from a script with :

ghb = GameObject.Find(“GroundHitbox”).GetComponent();

This produces a MissingComponentException, but only from time to time.
I could not find anything similar on Google, execpt [this Thread] ("There is no box collider attached..." yes, there is! - Questions & Answers - Unity Discussions), which advised to restart Unity.

This helped indeed but only temporary and after a time, without script changes, the Problem starts again.

Is there a better way to implement this, as the collider also seem to not call “OnCollisionEnter2D()” and “OnCollisionExit2D()” correctly.

hi;

u are not getting any component here :
ghb = GameObject.Find(“GroundHitbox”).GetComponent();

u should get it liket his :

        ghb = GameObject.Find("GroundHitbox").GetComponent(BoxCollider2D);

if u still have problem for finding it u can define a variable like this :

    public BoxCollider2D mycollider;

then assign it in inspector and use it where ever u like ;

about the second error:
it seems u dont assign a collider to that children or u may assign a wrong collider;

check and see if u set the exact "BoxCollider2D " to “GroundHitbox” GameObject ;