Optimizing endless runner
I’m taking a Unity game that wasn’t made with mobile in mind and optimizing it for tablets. Currently the player and camera don’t move while everything else does. It’s not really a runner, but it’s close enough. So my question is, is it better to have everything static and take advantage of static batching, and have the player and camera move (with some compensation to avoid float overflow)? Or should the player and camera not move and everything else move?
Any suggestions?
Thanks!
Moving objects around the player is better in this situation, as there is a loss in precision when dealing with large distances from the zero world origin (0, 0, 0). Unless you plan on somehow resetting the player and camera position back to start without the player noticing, it’s better to move the objects instead.
I am working on an endless runner right now, and have an object pool script that shares pooling with 3 spawn points. The objects that are spawned receive velocity on Start(), and watch their position relative to the main camera’s view. When they leave the visible area, they deactivate themselves and return to the pool. The player and camera are always docked to their origin, so there is never a need to reset their positions or worry about precision loss.
i think for a simple game, having a simple structure is more important than very very small optimization (if you check the profiler, you notice that rendering consumes most of the time), so i recommend moving the camera & the player.
Move camera with player…that has more advantage than moving ground itself…