godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.07k stars 69 forks source link

Make autotile recalculation more consistent and controllable when using pencil tool/ copy-pasting #3200

Open Proggle opened 2 years ago

Proggle commented 2 years ago

Describe the project you are working on

I am working on a little project based on heartbeast's metroidvania tutorial ( https://github.com/uheartbeast/metroidvania ).

Describe the problem or limitation you are having in your project

Painting with autotiles is a bit of a pain when you are mixing between autotiles and nonautotiles in the same tileset. Copy and pasting behaves in an odd way that is unexpected.

I'm going to use the first area of the metroidvania as an example. Here is how the level looks by default in the editor: image

Let's say we want to thicken the ground. If we just run the autotile along the bottom edge, we have a problem - the slopes mean that the autotile adds some borders in the middle of our black block. image One option you might think would be able to solve this is copying a section of the proper black tiles, and pasting it in.

image However, this does not work. When you paste a line of tiles, it appears that it does not override autotiles or recalculate them. Here I have pasted this five-tile horizontal segment three times in a row. Only the bottom one (outside the image) causes any change.

image Okay, so instead I disable autotiles, scroll through, and place a pure black tile over our problem areas. I also right-click to erase the five-tile segment I added in the previous step

image

I decide to thicken this ground area some more, by selecting the bottom two lines and duplicating them. image image

This is a very strange outcome. What happens if I right-click to erase in the middle of that dark area?

image

That's unexpected (I would have thought it would be a normal donut, as if I place normally image

I assume what's happening is that autotiles do not always get recalculated when they get poked with the pencil tool, and that disabling autotiles and treating the autotile as an atlas sets some kind of invisible flag(s) on the the placed tile/adjacent tiles.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

I suggest Godot should be more consistent on how autotiles get updated when drawing.

If you have autotiling enabled, the tiles you modify and their immediately adjacent tiles should all recalculate which autotile to show. This should happen regardless of whether you're using the pencil tool, line draw, rectangle paint, or copy and paste.

Currently if you have an image like this: image Clicking in on either of the middle two lines will not do anything. Under my proposal a normal click would do this image As it would recalculate the tiles around your click point.

However, if you are pasting a copied segment of tiles, and hold down shift, godot should do no autotile recalculation, and just override with the exact tiles chosen. This would mean being able to duplicate segments of the map more easily. Since this is a 'paste without formatting/paste verbatim' feature, godot should also paste blank tiles exactly and erase whatever was there to begin with (effectively letting paste holes into things). The eraser tool should also have this functionality as well, so you can erase a specific tile without recalculating adjacent ones.

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

See above.

If this enhancement will not be used often, can it be worked around with a few lines of script?

I don't think it can be.

Is there a reason why this should be core and not an add-on in the asset library?

Placing tiles should be easy, this makes a core part of level design easier and more consistent. To be honest, I don't really understand the current behavior at all.

I know there's a big rework of tiling currently in progress. However, I didn't see anything specific about autotiles / verbatim pasting so I figured I would suggest this anyway.

hsandt commented 1 year ago

I found this video for Godot 3: https://www.youtube.com/watch?v=dCL687AQbHM

It exploits the fact that you can reuse the same tiles for two auto-tiles, a flat one and one with slopes. It also adds a script to detect tiles from a different auto-tile set and join them.

I tried the same in Godot 4 but you can only paint one Terrain per tile so it doesn't work unless you duplicate the whole spritesheet (or split it in two versions, one with slopes and one without).

Ultimately, a 2D terrain editor where you draw the surface and it places the appropriate tiles smartly would be ideal, but I only saw that in level editors using HD textures (like Unity sprite shape). I suppose it could be adapted to tiles with fixed angles, but that'd be a very different system.

EDIT: I started a discussion specifically for Godot 4: https://github.com/godotengine/godot-proposals/discussions/6157