- Home /
Is it possible to make a camera update only once every X seconds ?
Hi ,
I am making a moba/rts like game, so i got two camera, the main one and the minimap one. The minimap camera is making me lose around 30fps on my frame rate, so i wondered:
Is there a way to make this minimap camera update every 1/4 second while continuing to display, so i got 3/4 of my 30fps back ?
thanks
Perhaps your $$anonymous$$imap calculations are too expensive? In my game, I use 3 cameras (ui menu, 2D background map, 3D object that moves) and so far no lag issues with camera.
If so, try using IENumerator to calculate every few frames.
I've wondered about the same thing, for an entirely different purpose. Basically running a non game simulation where the accuracy and speed of calculations are more important then the rendering. The idea would be to run Update as fast as possible, but only render three or four times a second. I didn't find a solution. I'd be interested if anyone has seen one.
@Bored$$anonymous$$ormon you can use InvokeRepeating to execute your tasks at certain interval that you require to run as fast as possible and set your FPS to be three or four as required. You can surely use InvokeRepeating to substitute Update.
@Harshad$$anonymous$$. I hadn't thought about doing it that way. I'll tuck it away for future use. I wonder how InvokeRepeating behaves if the method takes longer then the repeat time. I might have to do some playing there.
Answer by Jeff-Kesselman · Jun 03, 2014 at 05:17 PM
Well you could enable the camera one frame every N frames and disable it in the next one. You would have to render to a texture in order to keep it for display (pro only)
But are you really sure that's your issue? It might be worth taking a closer look at the code with the Profiler.
if i enable/disable the camera, i will have a "flickering" effect that i dont want. the effect i am looking for is really a freezing image. about the rendering to texture, i am not even sure it would be worth as the full process of writing an image could be heavier that the normal camera update, anyway i dont have unity pro so i cant do that or either profile the project.
the extra draw calls are not really an issue, they are just slowing the frame rate, thats all. and i need those.
Answer by Kiwasi · Oct 01, 2014 at 06:16 AM
For mini maps the best performance solution is to have the minimpap camera render only one layer. Attach a symbol GameObject (simple sprite or quad with an image) as a child of every GameObject you wish to display on the map.
Of course you should ensure the main camera doesn't render your symbol layer as well.
Your answer
Follow this Question
Related Questions
Minimap camera display size. 1 Answer
MiniMap with player and object icons 1 Answer
How do I attach a Camera to a GUI (for a Mini map) 4 Answers
Camera placement / size behavior 3 Answers
Getting Camera View (Mini-map) 0 Answers