Parallax only within certain coordinates

My game is 1920 pixels wide, and I have the camera centered on the player. However, I have the camera following the player within limits (0,0 to 10000,1080). The level stars with the player with a X position of 100, so the player has to walk a bit to get to the center of the screen before the camera starts to follow him. Once the player hits the end of the level, the camera stops moving and the player moves away from the center to the right side of the screen.

I have four layers behind the base layer with parallax effect. However, since their movement is based on the X location of the player, they move before the player gets to the center of the scene. This looks weird because the base layer isn’t moving but the other layers are. Is there a way to have the parallax effect only start once the player is in the center of the screen?

Below is the parallax code, the a gif of what i’m talking about.

parallax

If I remember your other thread, you’re centering your main camera on Ozzy within limits, correct?

If so, change the X position of the other cameras based off that first camera’s X.

So basically, instead of Ozzy.X() * 0.5, you’d use CameraX("", 0) * 0.5.

If you’re not centering the main camera within limits, this may not work.

3 Likes

Well I’ll be…worked like a charm. LOL. I can spend days troubleshooting an issue then post it on here and it’s solved in 5 minutes. Go figure! Below is the code the works in case anyone finds this in the future and needs a solution.

6 Likes

고맙습니다.
GDevelop를 시작한지 며칠밖에 안돼서 모르는 것이 많아 괴로웠는데 덕분에 해결 됐습니다.
물론 이 문제를 질문해주신 질문자분께도 고맙고요. :smiley:
두분 모두 정말 감사합니다.