In my 2D game, there are some circles randomly placed and some balls.
Each ball has a reference to one of the circles and this circle will apply a force to pull the ball to its center.
However, balls can change their circle. When they do, they fly from the current circle to the new one.
My question is: how to let balls only collide with balls that belong to the same circle? In the moment that a ball changes its circle, I want it to ignore collisions with all the other balls, except the ones which belong to the same new circle.
As I can have a lot of circles, I don't think using collision layers will do the job, so is there a better way?
You could go through Physics2D.IgnoreCollision
and store your balls in separate collections.
Then
IgnoreCollision
to false
for those.true