how should i call or summon my child...

Hi guys really nice to meet yall :3


I got a character and it has a child object (invisible trigger collider).
the child is like attack box or attack range.
if something nasty is in that area of box (IN RANGE), player character will stop moving and swing his axe like maniac.

so i used OnTriggerStay2D on player character script to detect enemy.

    void OnTriggerStay2D(Collider2D collider)
        if (collider.gameObject == Target)
            Debug.Log("Swinging AXE >:0");

and it worked fine! but as you can see i didn’t use THAT child object.
instead, i just made secondary trigger collider on player character.
because i don’t know how to call or summon child or other external object to the script and apply it to OnTriggerStay2D method…

so noob q_q.

can you teach me how to call child (or out side object) and apply to OnTriggerStay2D method?

MonoBehaviour.OnEnterTrigger(); - I am quoting from the Script Reference, “Sent when another object enters a trigger collider attached to this object (2D physics only).” meaning, if you want to use it as a child you have to write a script just for the child object, then you can just return a boolean to your parent script. You can simply get the value by making a reference or using GetComponent.

Another alternative would be using Physics2D.OverlapCircle - which would completely eleminate the need for the child collider.