[Solved] Making an empty (collision) object

Hi there. I’ve already made some games, but I can’t seem to get around this problem with my expirience.
I’m making a game with a ball in the middle, and empty circles (just the border), and some space cut out, so the ball can fit in and out. (These circles rotate and the ball only moves left/right and tries to get points in the circle.

The problem is that when my ball collides, it restarts the game, but I can’t make a proper collision mask that covers the borders, without the circles over-lapping(the maskpoints cover the border, but the inside too, so the ball can’t get in without reseting the scene) and making the mask with +30 mask points is ridiculous and laggy, and I can’t make it work out.

So I was wondering if there was a way of making an empty circle, with only the borders with collision.

By the way, English isn´t my mother/native language, so sorry for the bad gramatics/wrongly used expressions. (I’m learning)

Welcome to the community, @Dev. Do you mean something like this:

You have a hole and a ball


And you want to put the ball inside the hole

And restart the scene
But the ball just doesn’t fit inside
imageimage

If that’s the case then you should snap (or what do we call that) you ball to the hole when it gets too near the object. Like,

If ball distance to hole is less than 5px
Change the variable INTO_THE_HOLE of ball set to 1

If the variable INTO_THE_HOLE of ball is 1 Then
Pick the nearest hole in the position ball.X(); ball.Y()
Change the Position of ball set to hole.X(); hole.Y()

Would you mind attaching screenshots of your game (collision mask, positioning in the scene, events…)? That’d make it easier to understand. Thanks!

:thinking: while I am not 100% sure i understood Dev’s question, i am pretty sure that is not what he was talking about. He clearly said that the ball goes through the circle and that the circle borders has holes. Additionally this code suggest doing the malpractice of using a number as a boolean, and isn’t snapping but locking the ball into the hole.

I’m assuming the @Dev means something like this (green wizard means collision between wizard and circle detected) :

HollowCircleCollider


In which case I’d suggest looking at multiple collision boxes on the object. Yes, it’s little bit of work, but game making isn’t always quick and simple. Here’s a screen snip of collision boxes for the .gif above :

2 Likes

Awesome! That´s exactly what I wanted to do! I´ll check it out
Thanks!

Ok. I´m definitely a begginer. But it´s good to know this. It´ll be handy for most of my casual games projects. So, thanks MrMen!