• 2D
  • Repeated image for parallax background

Hi,

I'm (very) new to Godot (running 3.2.1 on Linux/X11), and am trying to add a Parallax Background to a scene. I have a 32 x 32 pixel image (png) that I'd like to repeat / tile over the entire background.

So I added the following nodes to my scene:

- ParallaxBackground
  `-- ParallaxLayer
       `-- Sprite

Now I'm trying to add my background texture image to the sprite, but can't figure out how to get it to tile over the entire region. The method used in the examples I found through google was to add the background tile image to the sprite texture, then enable "Repeat"; but these examples were using an older version of Godot.

However, when I add the PNG directly to the sprite "Texture" (load, or drag-n-drop), it gets automatically added as a "StreamTexture" - which doesn't have the "Repeat" property.

If I try and force the sprite texture to be an "ImageTexture" (which does support "Repeat"), then load my PNG into that, I get the following error:

The selected resource (StreamTexture) does not match any type expected for this property (Image).

I guess I'm going about this the wrong way for Godot 3.2.1. Can anyone point me in the right direction?

Thanks in advance,

Chris.

In case the above isn't clear, this video (using an earlier version of Godot) from t~=3:55 shows what I'm trying to achieve, just that I want to tile/repeat a much smaller texture over both x & y:

I'm not sure if it would work, but you might be able to use the texture with a TextureRect, and then set the expand mode of the TextureRect to repeat and change the size to whatever you need. I have not tried it myself, but that is what I might look into.

Also, welcome to the forums @Chris660!

Thanks @TwistedTwigleg - I have succeeded at getting a tiled ParallaxLayer using a TextureRect as you suggested. I added the TextureRect as a child of the ParallaxLayer =) -

- ParallaxBackground
    - ParallaxLayer
        - TextureRect

Set the StretchMode of the TextureRect to "Tile", then resized it to fill my level.

This approach definitely gets the job done for now, but I'd still like to understand why Godot seems to be forcing the texture of a Sprite to be a StreamTexture, and would also be interested to know whether there's a more idiomatic (and efficient?) way to do this.