Cost of instantiation

So, I am making a game that requires most assets to be continually instantiated. Or, at least, partially. It is an infinite runner type game where all the obstacles are randomly generated.

My question is, what is the cost of instantiation? The assets themselves are low poly, most being under 500 polygons. (if that matters).

Furthermore, this is for mobile.

Instantiation is high-cost, especially on mobile. You shouldn’t use it continously. You should use object pooling instead, so you instantiate a bunch of stuff in advance, and store them in a pool, and from there you can re-use them, you can even randomly select objects from the pool. More info on this:

Simple Reusable Object Pool - Help limit your instantiations!

Video tutorial on Object Pooling

Do a search here or on the web, you’ll find many more resources.

The complexity of instantiated objects doesn’t make a noticeabel difference in my experience.

I don’t have exact values, but as long as you don’t instantiate multiple objects every fram, you might be fine, but I would run some tests on the target platform. If it doesn’t work, you’d have to reuse objects instead of creating and destroying them, which might be a good idea anyway, because objects don’t get cleaned up automatically and you need only a small number of each object simultaneously.