I’ve been facing an issue where objects on different layers behave strangely when the camera follows the player. Here’s what happens:
When I place objects (like NPCs or collision boxes) on a layer that should stay still, they appear to move closer to the player as the camera moves. This doesn’t make sense because I want these objects to stay in one place while the player moves.
The camera seems to be affecting these objects even though I’ve set them to be fixed, which creates an illusion that they are moving when they shouldn’t.
As a game developer, it’s really frustrating to not have precise control over which objects move with the camera and which stay still. It leads to unexpected behavior that messes with the game’s design.
Has anyone else experienced this? I’d appreciate any suggestions or fixes. It would be great to have better control over how layers interact with the camera.
Please share a screenshot of your actions/conditions.
If the issue is moving the camera in one layer only (leaving it static in the other), this isn’t a bug but a programming error.
To clarify: moving the camera in one layer while leaving it static in another makes objects appear to float around the character instead of staying fixed to the map. This is a common rookie mistake—setting the camera to follow the player in one layer but forgetting to adjust it for others.
Share your actions/conditions for further assistance.
Thanks for your response. I’m experiencing an issue where objects on different layers, specifically collision objects, behave unexpectedly when the camera follows the player with a parallax effect applied.
Here’s what happens:
I’ve set the camera to follow the player (Captain_player) on multiple layers, with different speeds for a parallax effect.
Collision objects, like the red lines representing the base of the stairs in the attached screenshot, are supposed to stay under the stairs.
However, during gameplay, these collision objects move closer to the player, causing a misalignment. I have to place these objects earlier in the scene so that they appear under the stairs when the game runs.
It seems there might be a problem with syncing the camera movement across different layers, which is causing some issues. Can you help with the following:
How do I set the camera to move correctly with each layer, so the collision objects don’t shift?
What’s the best way to handle parallax effects, especially with interactive objects like collision boxes on different layers?
Also, should I do something similar to how I handled the red lines for the stairs collision, by placing the collision boxes before adjusting the camera, so it moves properly with the player? Or is there another approach I should follow to keep everything aligned?
Cameras visual location on the viewport have nothing to do with their actual coordinates.
As mentioned elsewhere:
Layer 2’s camera may be centered at 500x 500y, but the stair object on that layer is still at the actual position of 700x 700y. If your player character’s position is at 700x 700y, it is still in collision with that stair regardless of where the viewport shows them.
Generally you should not have collision focused objects on different layers than each other if the viewports aren’t actually synced, or you will need to build out some pretty advanced inverse positional math and your own collision logic rather than something out of the box.
Parallaxing is generally done for visuals only, not interactive objects.
Also, your current events mean the 2nd and 3rd layer are going to move substantially faster than the first layer (background), so the player and NPCs are going to appear to move much further and faster than whatever is in the bg.
Edit: Just to give some real world context, cameras on layers act the same as cameras in real life.
Even though you can tilt the perspective or zoom the camera to make two objects on completely different planes (distances) appear very close, they will only ever touch if their actual positions in the world touch, regardless of what the camera is showing.
I just want to thank everyone for the incredible support! As a newbie, I was struggling with parallax effects and layer management in my game, but your advice helped me understand the importance of keeping collision objects in non-parallax layers (like the base layer) to avoid misalignment.
Your guidance has made a big difference, and I’m excited to continue improving my game. Thanks again for all the help!