My CrashDetector script is not working properly

So everything was fine up until I added the delay code in CrashDetector.cs…

It delays fine, but for some reason my player clips incorrectly. He does the ‘upside down’ thing where the snowboard still has collision, but his top circle2d collider doesn’t stop his body from going through the ground.

Before adding the delay code, my players falling over “crashing” correctly resets the level…but after adding it…it doesn’t. I can’t figure out why.

I know the answer is fairly obvious…but I can’t figure it out.

After a bit of testing: I know the collision works (player slide on his head NOT under the ground) when the ‘is trigger’ box is UNchecked and no delay or scene reset is called…but when I make it a trigger…the delay works and the collision doesn’t…what?

I have the 2DColliderCircle on the parent object right? or is it supposed to be on the ‘player top’ object? I’m a bit stumped…I’ll have another try tomorrow

Hi Monstertank,

Could you please share screenshots of the problem in Unity?

Actually, Rick’s Barry should have dived into the ground instead of bouncing off. In later videos, you can see, that he doesn’t bounce anymore. Rick suspects that the surface effector made the head bounce in this case. Sometimes, there are undesired side-effects, and since we didn’t write the Collider2D classes or the surface effector class ourselves, we cannot prevent those side-effects.

If you prefer the head to bounce, you could uncheck “is trigger” in the Collider2D component. In your code, you would have to use the OnCollisionEnter2D method instead of the Trigger method.

Did this help?


See also:

Thanks for replying.

So basically this is happening:

but when I make it a trigger:

Here are my scripts:

I’m fine to continue with this happening, I just was wondering why it did?

OnTriggerEnter2D works with trigger colliders only. If you untick “Is Trigger”, the collider becomes a non-trigger collider. OnTriggerEnter2D won’t get invoked anymore.

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms