Check out our latest project ✨ OpenChapter.io: free ebooks the way its meant to be 📖

TileMapCollisionManager

An asset by [email protected]
The page banner background of a mountain and forest
TileMapCollisionManager hero image

Quick Information

0 ratings
TileMapCollisionManager icon image
TileMapCollisionManager

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 projectAttach 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.

Supported Engine Version
4.0
Version String
1.0
License Version
MIT
Support Level
community
Modified Date
4 hours ago
Git URL
Issue URL

TileMapCollisionManager — Lite

Stop fighting your engine. Ship faster.


The Problem

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


The Solution

Drop script.gd onto your TileMap node. It builds a name→index cache at startup and exposes a clean string-based API. Call set_collision_enabled_by_name("Ground", true) instead of set_layer_enabled(2, true). Your code survives TileMap restructuring.

No plugins. No autoloads. One file.


What's in the Lite Version

  • Automatic name→index cache built on _ready()
  • set_collision_enabled_by_name(name, bool) — single layer control
  • refresh_layer_cache() — rebuild cache after runtime structural changes
  • Inspector-configured initial collision state on scene load
  • Duplicate layer name detection and warnings
  • Debug layer map printing

What's in the Full Version

The full version adds batch methods (enable_layers_by_name, disable_layers_by_name), global toggles (disable_all_collision, enable_all_collision), and state serialization (get_collision_state_snapshot, restore_collision_state_snapshot) — essential for save/load systems and cutscene state management.

Full version on itch.io: https://nullstateassets.itch.io


Quick Start

  1. Copy script.gd into your Godot project.
  2. Attach it to your TileMap node (replaces it — TileMap is the base class).
  3. Add your layer names to initial_enabled_layers in the Inspector.
  4. Hit Play.

Compatibility

Engine Language Tested On
Godot 4.x GDScript 4.2, 4.3

License

MIT License. Free for personal and commercial use. Attribution appreciated but not required.

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.

Reviews

0 ratings

Your Rating

Headline must be at least 3 characters but not more than 50
Review must be at least 5 characters but not more than 500
Please sign in to add a review

Quick Information

0 ratings
TileMapCollisionManager icon image
TileMapCollisionManager

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 projectAttach 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.

Supported Engine Version
4.0
Version String
1.0
License Version
MIT
Support Level
community
Modified Date
4 hours ago
Git URL
Issue URL

Open Source

Released under the AGPLv3 license

Plug and Play

Browse assets directly from Godot

Community Driven

Created by developers for developers