I want to know something about performance in Unity games. I have a game where some objects (rather large number) appear in the screen, move somewhere and then disappear when they are beyond the screen.
First, I may use Instantiate to create them and then Destroy to remove them when they are away. Is it good for performance?
Is it worth to use pools? I mean to have about 50-100 ready objects, take them from the pool if there are some ready to be used (beyond the screen already), or Instantiate a new one if there are no ready objects.
Has anyone checked performance? Maybe someone has compared these two ways already.
In my book (Object Pool) > (Basic Instantiate) especially for objects that have a rapid create / destroy sequence.
They’re straight forward / quick to setup so you’d be able to test your specific implementation from code based on the pooler on the wiki.
Will it make a diff for you? Likely.
Instantiation and destroying are heavy operations, it takes a lot of time on mobile devices, so pools are definitely better in some cases, e.g for often spawning bullets.
From personal experience, my mobile game framerate improved a lot when I added object pooling for enemies and bullets.