- Home /
3D Health Bar - Killing My FPS
Hello,
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?
Thanks.
Answer by Cherno · May 22, 2014 at 11:14 AM
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.
If I don't update it every frame, then it would appear laggy as I move the camera around the scene. Worse if I update it ever second.
I want it to appear as a GUI, but not actually be a GUI element. GUI Textures don't work every well when following the unit above the head either.
Your answer
Follow this Question
Related Questions
Health and ammo GUI not working on re-spawn 0 Answers
Show GUI only when looking at an object? 1 Answer
Can't move GUI 1 Answer
Health - Inverse GUI Health Bar 1 Answer