- Home /
Infinity runner - best way to spawn board in runtime.
So Im'm making infinity runner game for Android, and I really don't know how to make this "infinity". The game will be 2D. I was thinking about make some prefabs with obstacles etc. and then instantiate them randomly. Is this good way to do this ? Give me some advice guys please.
Don't just instantiate. Ins$$anonymous$$d, create a simple object pooler that lets you re-use objects that are no longer needed. This can be everything from level parts to projectiles, enemies and particles.
Okay but, new objects which has never been used have to be instantiate first, and then when they will cease to be useful move them to the pooler object, or destroy later when they can't be used again. Am I right ? Or you mean just to have them all inactive on scene ? And use them just when are needed.
Yes of course, first the pool has to be filled :) Don't destroy objects if there is any chance they can be reused. Just disable them. The pooler keeps a list of objects, and tracks each one so it knows if one is disabled and thus can be used again.
Your answer
Follow this Question
Related Questions
How to generate different diagonal platforms? 0 Answers
2D Projectile Not Firing Based on Rotation 1 Answer
Instantiating Child - Prefabs 1 Answer