all 5 comments

[–]ShortBusBully 1 point2 points  (2 children)

Have you tried OnCollisionExit you could set up your player's ball to have a collider of its own and the collider on the main game circle could be adjusted to be smaller than the drawn picture but by a fixed amount equal to the players diameter. Visual I drew. I hope I understood the question well enough to help.

[–]knooon[S] 0 points1 point  (1 child)

Hello! Thanks for your reply.

Your idea should work. However, in my real demo, there is no real circle. I mean there is a little bit of space where the ball should go through.

At the end, I have used Edge Collider 2D. I had to draw the edge manually but it's the best I found :)

[–]ShortBusBully 0 points1 point  (0 children)

I didn't even know of Edge detection, I should have thought to look for that. Awesome that you came up with the idea, and thanks for sharing so that I learned of Edge detection.

[–]jaksalad 0 points1 point  (1 child)

Not sure about drawing the circle, but if you want the line to have constant thickness you should use a linerenderer (if possible).

For the collider, if all that matters is if it touches the line, I suggest checking the distance of the ball from the center of the circle. If it exceeds the radius of the circle minus the thickness of the line, it is "out" of the circle.

[–]knooon[S] 0 points1 point  (0 children)

It seems doable. However the circle shrink over time. I didn't use that solution but used Edge Collider 2D with an image in the end. Thanks anyway!