I am trying to make a system that groups script objects into ‘chunks’ based on the positions. I thought about using a Dictionary where the key is a Vector2 and the value is a list of scripts. I want something like this because getting nearby scripts would become very fast.
Unfortunately, I see a big problem with this method: I would need to update the objects every frame (Check if they moved a chunk. Delete them from the previous chunk. Add them to the next chunk).
Is there a more efficient way to do this wile still using a hashset-based system like Dictionaries? If not, how can I optimize this method?