godotengine / godot-proposals

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

Add options to enable/disable a TileMap Layer's collision and occlusion #10121

Open MarblesFr opened 1 week ago

MarblesFr commented 1 week ago

Describe the project you are working on

A 2D side-scrolling tile based game

Describe the problem or limitation you are having in your project

I want to have the option to use the same TileSet that I use for my playable terrain for background tiles. Background tiles should of course have no collisions and probably also should not occlude light.

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

By adding the option to enable/disable collision and occlusion I can simply use the same TileSet for gameplay and background without having to create new tiles.

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

For collision we simply have to expose the already existing collisions_enabled variable in the TileMapLayer and for occlusions we'd have to add a new occlusion_enabled variable that forces cleanup of occluders.

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

One could probably generate the a new TileSet without colliders and occluders from code, but it's not a nice workaround since any updates to the original tileset would also require regeneration of the second one.

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

This improves the flexibility of TileMapLayers allowing a wider range of applications.

KoBeWi commented 1 week ago

For collision we simply have to expose the already existing collisions_enabled variable in the TileMapLayer

It's already exposed.

Also even without it, it's possible to use _tile_data_runtime_update() to enable/disable any part of the layer.