In a project I am working on I need to create a large number (thousands) of simple identical objects (spheres) that float upwards at a constant velocity. There are “animals” in the world that feed off of these objects, and so need to detect which ones are in range and then eat the object on collision. Having thousands of objects with attached colliders and having each animal track nearby food and check for collisions is obviously very expensive and is currently bringing my FPS to a halt.
So, what are some tricks I can use to handle this? Here are some constraints that could dictate viable solutions:
Food pieces move at a constant velocity and don’t need to respond to ANY collisions besides being destroyed when an animal touches them.
Animals need to be able to detect their closest food source, move towards it, and destroy it upon collision. The collision does not have to be pixel perfect.
Food pieces are 1-2m in size, animals range from 2m-11m.
Animals and food pieces are roughly evenly distributed in a 5000mX5000mX5000m box.
Thank you in advance for any help.