TileMapCollisionManager's icon

TileMapCollisionManager 1.0 Scripts 4.0 Community

Submitted by user [email protected]; MIT; 2026-03-02

Name-based collision layer management for TileMap in Godot 4.x.

TileMap.set_layer_enabled() takes a layer index — a raw integer. Your layers have names. Every time you restructure your TileMap, those indices shift silently and your collision code breaks with no error messages. You are manually maintaining a number-to-name mapping in your head.

This script builds a name-to-index cache at startup and exposes a clean string-based API. Write set_collision_enabled_by_name("Ground", true) instead of set_layer_enabled(2, true). Your code survives TileMap restructuring because it never references indices directly.

Features:
- Name-to-index cache built automatically on ready
- set_collision_enabled_by_name() for single layer control
- refresh_layer_cache() to rebuild after runtime structural changes
- Inspector-configured initial collision state on scene load
- Duplicate layer name detection with warnings
- Debug layer map printing via Inspector toggle
- Zero dependencies — works in a blank project

Attach TileMapCollisionManager.gd to your TileMap node. It replaces TileMap as the base class. Set initial_enabled_layers in the Inspector. Done.

Godot 4.x only. GDScript 2.0.

Extended version with batch methods, global toggles, and state snapshot serialization available at nullstateassets.itch.io.


View files Download Submit an issue Recent Edits