Move the camera or move the sprites? Efficiency

I’m working on a game where there are a lot of paralax, layers, and sprites moving at different speeds from left to right.

My question is, what is more expensive for the engine?

A)The camera is fixed and the sprites move from right to left, like any typical endless runner.

B) Generate the sprites and move the camera to the right at different speeds depending on the layer.

Intuition tells me that it may be more expensive to move 40 sprites at the same time than to leave them fixed and move the camera, but sometimes intuition fails, and after all in one way or another you have to render the same sprites that move across the screen.

1 Like

Hi!

I think your interrogation is just by curiosity before to go deeper in your game.
Or perhaps you have the idea to choice the most efficient game engine to make your game.
All you say is not very a handicap for GDevelop, except if you have the project to create an ambitious game.

A+
Xierra

It is a problem for older tablets or smartphones.

Ok. In all the cases, me i optimize my games. So, the game will run on many platforms.
It is a good attitude to have, i think.

A+
Xierra

I do think the former is more expensive. You would rather have one action for moving than a ton for the same effect.

1 Like

Hello shinkitune!

I don’t know the answer for your question about what is more expensive, but I want to add one point.

I thought about using a fixed camera for my game in the third level. It’s a level where the character follows a river on top of a floating tree trunk. I soon realized that the gameplay results would be different. With the camera still and the background moving, if I walked forward (to the right where the trunk was supposedly moving), my character would move as if he were on top of a stationary log (because it’s stopped). But when I set the camera to follow the trunk and made the trunk move, the result was different. When I jump to the right, it seems like the character is slower, but it’s not, it’s because the trunk is moving to the right too. Okay, I know this sounds obvious, but before testing it I hadn’t realized this would happen. I was just thinking of the simplest way to do it.

So, my point is: maybe your choice isn’t just about performance. Maybe you should think about whether there will be any impact on your gameplay too.

1 Like

In my case it is a game in which you do not need to move the character directly, that is to say that the movement mechanics are secondary, so I am more interested in everything going smoothly.

(In the end I have chosen that it is the camera that moves and generates the world in real time)

1 Like

If you can test something
You should test it

I am spawning tons of rain drops which hits ground and i don’t see any problem

You could press E
But spamming Q would give better effect
Tilde to reset scene

In both cases you have moving objects and camera is still

So there goes your efficiency
Camera or object move but about how many objects you have and what you are doing to them
If you delete what is not needed and have only that is actually need when it is needed then you can fake there being TONS of objects run game at 60 fps

Where in my eyes you are asking very wrong question
Cause look at that 2nd game
If my planes would stop and i would move camera instead of planes themselves
Then camera is moving up plane stops BUT because camera moves up it will fake plane move down
So i need to move plane up at same speed i move camera to compensate camera movement
What if i want plane to shoot now and recoil up?
I need to compensate even more

Moving camera vs moving objects will vary from game to game which is better

Where efficiency will be terrible NO MATTER what you do if you have tons of objects that does not need to be there

I will admit moving camera is more efficient
But then you will need to compensate camera movement to move your objects if they need to move
So in the end you will save SOME performance but you will diminish that by combating camera movement to make your objects move

Where what you should really fight against is having tons of objects off screen