3D Health Bar - Killing My FPS


All my units have a 3D health bar - which is basically a quad that faces the camera:

transform.rotation = Quaternion.LookRotation(-Camera.main.transform.forward);

When I have about 40+ units spawned in my game, each with their health bar showing, my profiler says my HealthGUI script is taking up about 70% - 90% of my CPU.

All thats in my HealthGUI is the line above, in an Update function. I mean - I know that its getting called every frame. But for my CPU to go to 90% ?? I have way more complex stuff going on in the background that doesn’t even make a mark in my profiler.

Whats going wrong here?


You could either randomly stagger the rotation upödating over several frames or even once per second (which would make it 24 times faster already), or forgo it completely and just draw a GUI Texture and/or Label of your units health above their heads.