I have my first runner game. Everything works fine. So, this question is about optimisation.
In my game, There are 15 platforms(road prefabs on which player runs). Randomly out 15 any 1 is instantiated and this keeps happening. When player passes a few platforms, The left behind platforms gets destroyed. I made a list to keep track of platforms and delete them last platform prefab ( list[0]). And new ones are instantiated ahead.
As the game approaches, It gets fast which means the operation of instantiating/destroying is happening more frequently now.
I read about object pooling. I understood the concept and I hold very strong opinion that I should use this in my game. I create an object pool. Works fine. Now my problem -
PROBLEM - How should I reuse object from my created pool? In my game, What I came up with is - The platforms that user has left behind should change position from back to forward( direction in which user is heading ). How can I achieve that ?
I followed these tutorials - https://www.youtube.com/playlist?list=PLLH3mUGkfFCXps_IYvtPcE9vcvqmGMpRK