- Home /
What uses less resources, a stationary camera with a moving background, or moving camera with a stationary background?
Hello everyone, I'm working on a game, in 2D, that features a cannon and something that shoots out of the cannon. The camera will then follow the cannon ball out of the cannon and go through different environments.
My question is, is it a better idea to keep the cannon ball and camera stationary and create a background that scrolls by. Or should I make the ball move through the unity space and have the camera follow it and create the background in front the camera and delete it as the ball move.
Which one of these options would be the most resource friendly. In addition, which one of these would be easier to code.
Any input is appreciated, if you need me to clarify anything, please ask me to.
Thanks for your help.
As a general rule... figure out the easiest way to make it work... then if it's not efficient... figure out how to make it more efficient.
Pre-optimization is the death of success.
Answer by AlwaysSunny · Feb 04, 2015 at 09:39 PM
In practice, efficiency tends to follow logic. At least in this case, it stands to reason that moving two objects is less expensive than moving hundreds. Even if it's all parented to a single object, (which probably should reduce internal calculations.. worth testing), it doesn't make the operation cost-free.
I guess if your environments go on and on such that you're already talking about deleting parts of it on the fly, you may need to load it on the fly as well. In that case, and depending on sizes and required floating point precision, having a moving environment might make more sense. All kinds of fiddly problems arise from atypical environments.
Also worth mentioning, if your environment is physically interactive, it's probably best to use the fixed environment. $$anonymous$$oving colliders around is expensive no matter what.
Awesome, This is great info to know. Thanks for your help, I really appreciate it.
Answer by DanSuperGP · Feb 04, 2015 at 11:41 PM
The moving camera is a tremendously better choice. The other ways is madness.