1

I'm having one of the most basic issue but I really can't get it work on my project. I even tried to re-create a blank project and create a similar situation, in this new project, the trigger is working well but not in my old one and I can't figure out why so I'm looking for help here.

Here is some explanation on what I have, first, the character :

 My character with : 
      Box Collider 2D with NOTHING check (so isTrigger, used by effector, etc, they are NOT checked) 
      Rigidbody 2D Dynamic, simulated, continuous and stat awake.

Then, the platform prefab :

 Platform prefab (BoxCollider2D with Used By Effector, Platform Effector 2D)
    Child of platform prefab > front part (just a sprite renderer)
    Child of platform prefab > triggerPart (Empty object scale 4,1,1 with BoxCollider2D with is Trigger checked and the script "triggerBounce"

Here is the script triggerBounce : (For now, I'm just trying to see if the trigger is working)

private void OnTriggerEnter2D(Collider2D collision) 
     {Debug.Log("triger in " + name + " " + collision.name);}
 
 private void OnTriggerStay2D(Collider2D collision)
     {Debug.Log("triger stay " + name + " " + collision.name);}
 
 private void OnTriggerExit2D(Collider2D collision)
     {Debug.Log("triger exit " + name + " " + collision.name);}

I searched a lot of help on the internet before posting this, like this :

  • Putting all the element on the same Z position to be sure they're triggering
  • Reproducing the most simple situation, which I made work in an other project, but not in this one
  • I checked that in my project settings > physics 2D the Y gravity was -9.81
  • I tried resizing the boxCollider2D size
  • Verified the script triggerBounce was launched by debug.log("start") in his start

And even tough I did all this, it doesn't work any better.

Here is a pic of the situation, it can help you understand the problem : enter image description here

3
  • If “isTrigger” is not checked then no. It wont call the trigger methods.
    – BugFinder
    Jul 6, 2022 at 8:37
  • isTrigger is not checked for the character, but it is checked for triggerPart which is a son of the platform (and that's the object with the triggerBounce script) Jul 6, 2022 at 8:48
  • Check layers and collision mask in the project. Perhaps your objects have layers that cannot collide with each other.
    – Morion
    Jul 6, 2022 at 9:00

1 Answer 1

1

Thanks to @Morion, I found what the problem was.

All my GameObject had the "default" layer and the collision matrix wasn't checked for 2 default.

So, I went to Edit > Project Settings > Physics 2D

and check the box where the row and column was default.

Collision matrix

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.