• Hey! Guest! The 40th (!!!) GMC Jam will take place between February 25th, 12:00 UTC to March 1st 12:00 UTC. Why not join in this very special anniversary jam! Click here to find out more!

Vertical Scrolling Parallax Issue

JeanSwamp

Member
Hello,

I've been tweaking my camera every now and then because after adding new features to it, I might run into new problems. Currently I am having issues with the vertical parallax scrolling my layers. This is for a 2D Sidescroller.

This is how I am scrolling the layer_y

GML:
var _ypos = camera_get_view_y(cam) /(room_height-camera_get_view_height(cam));
Code:
if room_height >= bg_size
{
    layer_y(layer_bg1,lerp(-(buff),room_height-bg_size+(buff),_ypos));
}
Code:
bg_size
is set to 400 and buffer is 16px used to make sure screenshakes don't show empty spaces on edges.

The problem I have is, when the room is heigher than the view size (therefore the camera will move on the Y axis) when on the lower parts of the room a simple jump by the player will trigger the vertical parallax, making it look weird and I am unsure why this is happening since I did not have this issue before.

Hopefully someone with experience can point me in the right direction.

EDIT: I might be overthinking it as looking into some games as examples, they do have similar effects. But still I'd like to improve my camera!

Thanks!
 
Last edited:
Well, if you didn't want that to happen (despite some other games using it) you could simply make it so that the vertical parallax doesn't trigger if the player is in the jump state by wrapping it in an if statement.
 

JeanSwamp

Member
Well, if you didn't want that to happen (despite some other games using it) you could simply make it so that the vertical parallax doesn't trigger if the player is in the jump state by wrapping it in an if statement.
I am not sure if that would feel better. I think the problem is coming up with a value that works for all room sizes
 
Eh, then it's just personal preference. If you don't actually need help with the logic then just run a few different test cases and go with the one you think feels more natural.
 

JeanSwamp

Member
Eh, then it's just personal preference. If you don't actually need help with the logic then just run a few different test cases and go with the one you think feels more natural.
I think I need help with the calculations on how the parallax scrolls. Old builds, if you were on the bottom of the room, jumping there wouldn't scroll the layers, however it will as soon as you gained some height within the level. Now after some mods to the camera, the scrolling is also happening on the very bottom of the room and I am unsure why.

Thanks for your replies btw!
 

Joe Ellis

Member
Are you trying to do this kind of thing?

I think that it works with a center y coordinate, where when the camera is at that point all the parallax layers will be at the same coordinate, then the further the camera is away from it the layers expand and become further apart. To give the feeling that you're looking up or down towards them. It'll also have a limit of how far they can expand (the height of the sprites for the layers)
 
Top