How can i store all colliders of colliders which collide with a prefab?


i have circle prefabs which have circle colliders 2d and rigidbody2d. i want this prefabs to store all colliders of colliders which collide with them. how can i do this? in the referance image, A can only get {B,C,D}. but i want to store all {A,B,C,D,E,F,G} objects in each object. I use collision enter and exit to do this. for example A; i can store the information of {B,C,D} in a list in A object. and i can get the {A,D,E} which collide with B and C. but no more i can access other objects. is there a way of it?

hello you can do some recursive function, first create a collision manager that will store all the colliders that are colliding. now you can start the recursive method, the method needs to pass one collider as argument so for example you start calling yourRecursiveMethod(a);

you create a foor loop that iterates over all the collider you have stored in the list, for each collider you compare if that collider has already been added to the list of all existing colliders inside the collision manager, and if its not you will call your same method from there but passing the collider you were comparing as an argument, that collider will do the same over and over with all the colliders untill you find all. remember you must compare if the collider was aded to the list and if it was just skip it, it might sound a bit complex but is no more than 5 or 6 lines of code.