- Home /
Game Objects: What's their cost?
I'm trying to get an idea of how to manage GameObjects in my game. Does anyone have a good idea how expensive they are CPU-wise, memory-wise? Likewise, Components.
For example, if I was creating a missile launcher that fired a cluster of 8 missiles, and several different ships are going to have this weapon, is it a bad idea to just spawn 8 Game Objects? What's a good budget for GameObject count?
Any insight is appreciated.
Answer by Adam Rademacher · Oct 16, 2010 at 05:02 AM
We have a project in which some scenes have well over a thousand game objects (some of which are empty locators, used for keeping things organized, etc.) and our performance is still quite reasonable for our target platform (a last generation mac mini). Our greatest draw is on rendering meshes (we have almost a million tris in these levels and dozens of materials), but the overhead of the gameobjects themselves is nearly inconsequential in comparison to the cost of rendering meshes and some fancy physics (A* pathfinding with capsulecheck obstacle avoidance, etc.)
In our experience, the greatest performance issue has constantly been in rendering--especially draw calls.
Answer by Bampf · Oct 16, 2010 at 03:44 AM
Not easy to answer this with a blanket statement.
The cost of dozens of game objects isn't significant, it's the other things that you put on them that'll cost you.
If you have a simple missile mesh, simple shader, simple capsule or sphere collider, and very little scripting, then no problem, especially on desktop platforms. If it's got a complex mesh, with a mesh collider, AI, a multi-pass shader, real-time shadows, lots of lights, the missiles don't all share the same material, there's transparency, and you intend to deploy to a mobile platform, then you have a problem.
Try instantiating 50 cubes around the scene as an experiment, then a bunch of game objects with a simple model to compare to. I highly doubt you'll see any significant slowdown with game objects, even using the profiler. Your tuning efforts will probably be concentrated on things like meshes, colliders, lights, shaders, draw calls, and sometimes scripts.
Your answer
Follow this Question
Related Questions
How to speed up my building Process for my 3D game? 1 Answer
Key input changing Label (Object reference not set) error 1 Answer
throw / fling object or prefab 1 Answer
When do _UseClipRect and _UseAlphaClip work in UI-Default.shader of newGUI? 0 Answers
How can I protect my assets on the Asset Store from piracy? 4 Answers