- Home /
Does moving around lots of unused naked tranforms consume cpu cycles?
If I have an object with a bunch of empty gameobjects with just Transform components as its children, but nothing attached to those- and the parent object is moving and rotating, is the engine keeping track of the position and rotation of each one of those points every frame, or are they only being recalculated relative to the parent when a script addresses one of them and ignored the rest of the time?
Either is doable, and no good way to know w/o a stopwatch. $$anonymous$$y guess, child world transforms are computed "as needed," each time you look them up.
I was worried about this late at night and thought I might have to redo something but really if I thought of this way to optimize the engine surely the pantheon of coders at Unity3D did too. I also was looking at switch-case statements and wonder if it matters to put the most likely chosen cases first or make them branching ins$$anonymous$$d of a long list one deep, but I think ultimately none of that stuff matters to framerate compared to adding one more light to the scene.
Answer by Paulius-Liekis · May 25, 2011 at 09:24 AM
World positions of child transforms are updated on demand, so if you're not accessing them and there are no Renderers/Physics/And other stuff on it then world matrices shouldn't be calculated.
On the other hand if you have lots and lots of them they might consume some performance, because Unity has to allocate memory for them and do some basic managment.
Your answer
Follow this Question
Related Questions
Pre-Emptive Optimisation Help 0 Answers
Getting screenshots within a loop? 2 Answers
transform.localScale very slow on device (contrary to Android Remote) 2 Answers
Is there any way to use parenting as an organization tool without creating a Transform bond? 3 Answers
Return array of transform 2 Answers