Hey there! TL;DR in bold below!

I've seen this question pop up quite a few times on the Reddit, but from what I found, only a handful were recent enough for Godot 4, and all of them refer to an isolated Sprite2D/TextureRect Node.

Basically, I have a texture.png that I'd like to use for solid walls in my top-down shooter - plop one down somewhere, resize to your liking, bam; new wall, with collision and everything.

Understandably, saving this Solid.tscn scene, adding one to the level, and scaling it (to keep the collider etc. proportional) does not result in the sprite tiling itself to fill the new space, but instead it stretches it.

Image & explanation below:

  • Background (box on the left) is a regular Sprite2D I've put in the root scene.
  • - Region = Enabled (and set to the size I wanted)
  • - CanvasItem > Texture > Repeat = Enabled
  • Solid is an instance of Solid.tscn as described above (StaticBody2D > Sprite2D, CollisionShape2D)
  • - Node2D > Transform > Scale.Y = 1.5 to show that the text gets stretched, i.e. it does not tile itself like Background does.

Basically, my question is: Is it possible to have a Packed Scene that will tile itself once scaled inside of another scene?

Note: the actual texture I have is like 2000x2000px -- I'll gladly trim it "down" instead of tiling it "up", if need be; I just don't want the hassle of manually setting the collision box to match the tiled sprite each time I edit it...

Thanks in advance!

what you want is to be able to create walls like in fornite but in 2d ?

    el_malo lol I did think it might be a cute mechanic, but no -- just level design. (That's the way I got used to doing it in Unity, at least 😅)

    el_malo Is that generally the solution to this kind of "dynamic-size repeating-pattern"? What about, like, hookshots - where the rope's length extends/retracts and the texture should just keep repeating, instead of stretching which would cause the rope texture to deform? Or flamethrowers - where the "line of fire" is (AFAICT) several "Fire" instances chained in a line?

    (Not talking about a specific game BTW - just how I've seen those two mechanics generally implemented in pixel-art games 😅)

    Generally speaking from past versions of godot: Don't scale colliders, adjust extents. There might be situation where you can get away with scaling a top level node that has a collider but colliders directly are best affected by adjusting their extents rather than scaling them.

    Don't recall for sure but there's always the possibility that in godot 4 something might have been changed to invalidate this advice/rule of thumb. But with the previous versions this has generally been true. Sadly physics has rather tended to be godots weak point.

    sidenote: the rope thing would typically involve a custom shader. Also colliders wise, the collider would likely not scale and only apply to hook or arrow at the 'end' of the rope/spline.

      Megalomaniak Ohhhh that's interesting, thank you! So would the best course of action be to adjust the colliders programatically? (not for the rope thing, for the wall thing) And as for the shader, would the same be true for, say, a laser beam?

        djohoe28 And as for the shader, would the same be true for, say, a laser beam?

        Not sure, depends on what you mean? Just a 1px line of green probably doesn't need it. But like a charged/PWM beam for an example would probably benefit from it. Though technically you could also try tweening the material texture UV parameters or key framing them via animation system.

        And the same about collider extents. You can keyframe them or you can tween them from code, both should be doable I think.

          el_malo I finally looked into TileMap, and it does seem extensive enough in Godot that it just might work..!
          Is there a way to make a TileSet Terrain that attempts to make the terrain... "contiguous"(?)

          For example, I'm using the Red Texture from Tatermand on OpenGameArt -- that texture is 1. tileable with itself (i.e. you can repeat it both horizontally and vertically) and 2. huge (2000 x 2000 px).
          I threw it into a TileSet (80 x 80 px), but not sure how to make it so that when I start drawing with, say, the tile at Atlas Coordinate (0,0), and then draw a tile to its right, it'll take the tile at Atlas Coordinate (1,0), etc.

          An interesting solution I found is selecting the entire set as a pattern, and using the Paint tool (D) with Draw Rectangle (hold Ctrl+Shift), which then draws only however much of the tileset that it has to. Only problem is it doesn't combine with existing tiles, so it does require some forethought. 🤔

          I figure this is solvable with Terrains, but the only solution I can come up with is making each tile a unique terrain that explicitly only connects to the specific 2-to-8 terrains surrounding it, and that seems really tedious...

          Megalomaniak Oh, cool! I haven't heard of PWM, but that really does seem to be the real world analogue of what I was trying to describe lol
          To answer your question, I meant something like this Kamehameha -- the beginning & end are set, but the middle part repeats as needed; in a grappling hook, the beginning & end would be the source at the start + the anchor at the end, and the middle would be the rope.

          The kamehameha I'd construct out of 3 pieces as separate nodes so nothing special needed in shader terms. The middle part would be only one scaling/adjusting. With rope you have the thread details and/or braiding or twisting that have to move realistically, which can need more special care.