An Object interacts with every other Objects

Hi, I have a class called “Boid”. My goal is that every Instance with the class “Boid” can update his direction dependent of every other Instance called “Boid”. I have implemented a list of the class “Boid” and my goal is to put every Instance in that list.
Has anyone an idea how to implement this?
Is it possible to do this in one script for the “Boid” or do I have to create a new Script for spawning the “Boids”?

Can’t you use FindObjectsOfType<Boid> to get all the boids? It would be better to create a class for a boid spawner, which stores all existing boids in a global list. Therefore, you don’t need to give every boid a new list each time.

I’m with Llama_w_2Ls. Try creating a new gameObject in-scene that does all the spawning of Boids. According to the API, when you use the function Object.Instantiate, the function returns a reference to the spawned object. So you should be able to take this reference and put it into a list or something to keep track of it.
Any time a Boid is destroyed, use the OnDestroy() function to tell the boid spawner to delete the reference to it.
I’m not sure if you’ll need to give each Boid a unique ID or something, but you can play around with this idea and see if you can make it work.