- Home /
How to keep track of multiple gameobjects inside collider
i have a circle collider but it seems to only look at the first game object to enter it in which case is my sword and ignore everything else.
void OnTriggerStay2D(Collider2D triggerObject) {
if (triggerObject.gameObject.name == "PlayerBox")
{
}
}
this if statement is never entered because sword is the first object to enter the collider
I suspect something else is amiss; change it to Debug.Log(triggerObject.gameObject.name) and see that you are getting the values you expect.
I tried that and im getting only sword ins$$anonymous$$d of playerbox
are you sure playerbox has a collider/rigidbody attached?
Thanks for the help, i had rigid bodies on all my objects, so i just removed and readded the components and it ended up working, I must have screwed up the with setting for rigidbodies.
Your answer
Follow this Question
Related Questions
How to pick up a game object using E 4 Answers
Kill Particles Entering 2D Trigger 1 Answer
Triggers not changing cameras 2 Answers
How do I make a button appear when my player enters a trigger? 1 Answer