Infinite Parallax Scrolling Godot 4

preview_player
Показать описание
Showing how to make parallax background scrolling
for 2D games in Godot 4

- Asset Used -

- Music Used -
- Hoogway - Orion
- Provided by Lofi Records
Рекомендации по теме
Комментарии
Автор

1:37 Thank you for explaining and solving "a case where BG is not the same size as screen width." I was running into that and did not know why it was "popping" in and out while moving the character.

shadowrunkarma
Автор

2 minutes and 41 seconds and I've learn more than in some 20 minutes long videos. Thank you !

TaianRmos
Автор

Thank you for this guide! Came in super handy during a game jam.

TimeTheTea
Автор

Poppin when changing window size was honestly such a pain I just edited the background image to repeat once then in the code continuously set self.offset.x -= 1 until the offset.x was half the file size then I set the offset.x back to 0 and that worked perfectly for me.

Wizardk
Автор

Thank you, this was very helpful as I was trying to figure out how this all worked together. I did find that you don't have to duplicate the parallax layer as you only need to duplicate the sprite and offset it under the same parallax node (Just in case you want to keep the nodes more tidy).

HailtotheTeo
Автор

Another way to fix the background image when it is a different size than the viewport.

* Replace Sprite2D with TextureRect.
* Set TextureRect's Transform > Size to the size of your viewport, or size of image, whichever is larger. Example: I have a 1024x1024 image and a 1280x720 viewport. I set the Transform Size to 1280x1024.
* Set TextureRect's StretchMode = Tile.
* Set ParallaxLayer's Motion > Mirroring to the size of the image. (eg, 1024x1024) for me.

Run the game and voila! no duplicate layers, no weird code offsets.

realdanielpeach
Автор

Another another way to do this is with Parallax2D node. It is currently experimental, but it is easier, and lets be honest, none of us are creating production games right now ;)

Also, it fixes the image-to-viewport sizing repeat issue by allowing you to set a repeat-times variable. That way you can just start off the tiling with enough repeats to cover the viewport!

realdanielpeach
Автор

How do I change the size when the screen is stretched? I'm just starting to learn Godot.

Furina-lcdl
Автор

great, was looking for something like this

Ralke
Автор

how to set a limit for down? my player is going way below the mountains layer

hanzo-ep
Автор

Greate video, explain everything and without to much bla bla bla!!!!

racine
Автор

can i use this without having a character without a camera or does a node with a camera have to be present and be moving for this to work? Can I have it some that the parallax works as soon as the game loads without having a player scene being needed to move?

Epsio
Автор

how do i make it work with resizing the window?(

TheRealMangoDev
Автор

Sorry for the late comment, but how do i know the screen width, im a beginner

chipperwhizz
Автор

podes hacer un tutorial que el escenario tenga un final cuando llega el jefe como el juego aero fighter de neo geo gracias

carlonsantosalberto
Автор

I'm criying lol it doesn't work for me, it's popping every try

maia