I am attempting to make a 2D platformer with guns that shoot towards wherever the user clicks on the screen. When using the "scroll to" behavior on the player, the screen moves up and down when the player jumps, and this makes it hard to aim at an enemy while jumping.
I already have tried to "on every tick" scroll X to Player.X and this works, however if the player jumps down a cliff he of course does not remain on the screen. I want to make the screen only move in the Y direction when the player reaches the very bottom of the screen or the very top.
I tried to create invisible sprites on the top and bottom of the window, with 0,0 Parallax, and then when the player is overlapping the sprites then make the system scroll Y to Player.Y - (half the height of window) (or plus for when hes at the top of the screen). This works exactly how I imagined only there is a lag so the player appears choppy while the vertical scrolling is happening. :(
Any ideas on how to make it smooth? Thanks!
I was thinking on this the other day and I believe you must have an invisible sprite that has the Scroll To behavior. He is positioned in the center of the place you want the level to start. I think it's a matter of moving the sprite's X (and/or Y) along with the player.
Just clicked me, maybe using Pin behavior it can get even better.
But I never tested, I just thought about it :P
Develop games in your browser. Powerful, performant & highly capable.
I typically use the method that siks described. Have an invisible object that has the scroll-to behavior, and have it update its x position along with the player.