Finding parent of collider, using boxoverlap.
Here is my code:
Collider2D objectOverlapped = Physics2D.OverlapBox(playerPos, size, 0);
GameObject objectParent = objectOverlapped.transform.parent.gameObject;
I'm first getting the Collider2D of the object in the OverlapBox, then in the second line im finding the parent of said collider. Any ways I can fix this, the error im getting is.
NullReferenceException: Object reference not set to an instance of an object
SelectOverlap.Update () (at Assets/Scripts/SelectOverlap.cs:34)
Thanks in advance.
Comment