Simply put, I am developing endless 2D game, where you can move character forward or backward using accelerometer.
There are lots of objects and I don’t know which method is the best for moving these objects and not decrease performance of this game.
Method 1:
I only use movement on X axis using accelerometer on my main character (or Player) where is attached Main Camera. It means that only main character is moving on X axis and other game objects are staying on their X positions. I used this method first, but then I realized that if anybody got really far in this game, there would be a problem with values on X axis, because this number could be higher than maximum value of float number. Yes, I know that it is highly improbable, but it might happen.
Method 2:
I don’t use movement on X axis via accelerometer on my main character, but use this value as inverse in RigidBody2D.velocity of all other objects. It means that X position of my main character would always be 0 and if I use accelerometer for moving main character forward (right direction) then I use this value as inverse on X axis of all other game objects.
So which method is the best for moving objects in 2D endless game? If you have any other which is better, I will be very thankful for it.