Why is the Edge Collider 2D not used?

Hey everyone,

Title is kind of self explanatory. I was wondering why, in the course, @Rick_Davidson uses three box colliders for the walls instead of one Edge Collider. This seems easier, or am I missing something here?

Thank you already for your explanation.

Cheers,
Ewoud

Hi Ewoud,

An EdgeCollider2D logs collision on its edges only. Unity cannot handle fast moving objects well. Since our ball is moving fast, it might be that it moves beyond the edge without Unity noticing it. No collision would happen.

Nevertheless, feel free to test an EdgeCollider2D in your game. If it does the job, you may keep it. :slight_smile:

Has your question been answered?

2 Likes

Hey Nina,

Thank you for your answer. I indeed didn’t think about the fast moving objects.
Just one question though, wouldn’t setting the collision detection on the ball to continuous fix that problem?
Of course this would make it more CPU heavy.

Greetings,
Ewoud

I don’t know if that will work. Maybe it will. You could also increase some iteration values in the Physics2D Settings. Ultimately, you’ll have to test your game on multiple devices to see whether your solution fixes the problem. If it does, you may keep it. :slight_smile:

Ben’s/Rick’s solution has been tested by thousands of students in the past few years. It works.


See also:

Hey Nina,

Thanks for your reply again. Of course, I did not mean to offend you or say that Ben’s/Rick’s solution was no good. I was just wondering about some other possibilities.

Thanks again for the fast replies and for the feedback. It helped me think some more on the workings of Colliders.

Greetings,
Ewoud

Don’t worry. I didn’t feel offended, and I doubt that Ben and Rick do. We are open to constructive criticism, and we don’t mind if students question something or develop their own solution. In the end, it’s called game development. Things are constantly changing. New ways are getting explored. :slight_smile:

I just wanted to point out that testing is crucial. Solutions often work on paper, and they appear to make sense when you see them typed out. However, there could be edge conditions that you (or I) haven’t thought about.

For example, we had an issue with Ben’s and Rick’s initial singleton implementation in this course a couple of months ago. For them and many students, it worked perfectly fine. However, for some students it did not. It turned out that their solution works by chance only because Unity internally executes scripts in an arbitrary order. Fortunately, Sam solved the problem.

Implement your own ideas and test them - if possible, on multiple devices. Ask friends to test them, too. Don’t rely too much on what people on the internet say or what you read because that’s theory in most cases.

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

Privacy & Terms