Is instantiating empty gameObjects heavy on the CPU? ( Object pooling)
Hello!
I'm working on an endless runnner game for mobile.
I have predesigned segments of the level that show up in a random order during the game. These segments have only emptyGameObjects as children that act as markers. The segment has a script attached to it that generates (using object pooling) actual obstacles and pick-ups at their respective markers.
After the player succesfully completes a segment, it should be destroyed, alongside the markers. A new segment should be instantiated in front of him. My question is :
When many empty game objects are instantiated at the same time , is that heavy on the CPU?
Maybe I should replace those markers with something else? How can I make the segment know the position of each element without using empty gameObjects as markers?
I hope I didn't confuse you too much. Thank you
Answer by rutter · Dec 10, 2015 at 11:33 PM
Empty GameObjects aren't quite free, but they're pretty cheap. Try it, profile it, and see if you run into any problems.
As with most performance questions, you should usually try the easy solution first, then see what it will take to improve from there.
Each GameObject does take a small amount of memory, and I've sometimes observed that creating a new object can take time if the scene is extremely busy. It's usually not a concern unless you're doing some really heavy lifting, though.
Your answer
![](https://koobas.hobune.stream/wayback/20220612052122im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to edit collision on objects that aren't spawned yet 0 Answers
Instantiate GameObject Error I dont know whats wrong with it seems right to me 1 Answer
Particle Systems. Stick inside pooled objects or pool them separately. 1 Answer
How to Bend Planes within unity? 2 Answers
Object Pooling Help 0 Answers