Hello,
I’m making a duplicate of stick hero.
I wanted to ask if in 2d sidescroller games, is it better to move the camera position forward or to transalate the gameObjects backwards ?
Hello,
I’m making a duplicate of stick hero.
I wanted to ask if in 2d sidescroller games, is it better to move the camera position forward or to transalate the gameObjects backwards ?
Sidescroller? Move camera left/right or game object left/right? I personally would do the game objects.
That’s a confusing question. What are “the gameObjects”? It’s best if you describe what you’re doing. Our answers can only be as clear as your question.
The camera is already “moving” everything. There’s no “camera” like we think of a camera. When you “move” this “camera” you’re changing the way the world geometry is transformed before it’s rendered. The “camera” abstraction is an easy way to avoid thinking about the way we must move stuff around prior to rendering. The camera does all this work for you. Just point and shoot. You can also take advantage of having a calculable position in the world space for events and so forth. If you move your level to the left, along with game objects, etc. You’re doing a lot more work than translating the camera and you’re doing more operations. Just use the camera.
This is true, but it’s only referring to one part of the rendering pipeline. Moving stuff in the scene is still moving stuff in the scene and moving two things (character + camera) is still (usually) far less work than moving many things (eg: scrolling the environment around a static character).
Plus, there’s stuff to consider like how the physics system works.
I think we’re saying the same thing. Basically what I mean is that there’s no benefit in leaving the camera in one spot. And moving the entire map rather than moving the camera doesn’t make a lot of sense for lots of reasons.
And yes, if you’re moving the world around the character, I had thought about how physics have the potential to get really weird. Like a cube sitting next to a wall might slide sideways when the wall “bumps” it, or momentum might take effect (like a rug pulled out from under somebody) if the character “moves” rather quickly.
Or everything has to be a kinematic rigidbody…
…these are the rabbit holes I try not to fall in. So I try to keep it simple.
If you’re doing an endless runner type game, it can be a good idea to keep a fixed camera and move the world around, this way you won’t run into floating point errors once your player and camera have moved far from the origin.
I was thinking about that “distance from origin” thing… I remember reading that Minecraft is fundamentally limited, once the world reaches a certain size the algorithm screws up. Sigh. There is no winning.
So the answer is, as usual, it depends…
If you’re trying to achieve an endless scrolling, then you move the objects by the camera and recycle level parts.
Otherwise, move the (%#&) camera.