Edit of asset "LayerStringHelper" Accepted
| Old/Current | New/Edit | |
|---|---|---|
| Title | LayerStringHelper | LayerStringHelper |
| Description |
Set physics layer collision masks by name instead of bitmask arithmetic in Godot 4.x. Physics layer collision masks are set as bitmask integers. Bit 1 is layer 1, bit 2 is layer 2, and so on. To enable layers 1, 3, and 5 you write 1 + 4 + 16 = 21. You recalculate this by hand every time your layer assignments change. One wrong number and your raycasts silently hit the wrong things with no warning. This script reads a list of layer names from the Inspector and translates them into the correct bitmask at runtime. Set collision_layer_names to ["Player", "Projectile"] and collision_mask_names to ["Enemy", "World"] — the script does the math. Features: - Configure collision_layer and collision_mask by layer name array via Inspector - names_to_bitmask() public method for code-side use without a target node - Applies automatically on ready (configurable) - Works as a child node or attached directly to the physics node - Auto-detects parent physics node — no explicit assignment required - Debug output prints computed masks as 20-bit binary strings for visual verification - Compatible with CharacterBody2D, RayCast2D, Area2D, and any physics node - Zero dependencies — works in a blank project Add LayerStringHelper.gd as a child of your physics node. Set layer_names to match your project settings. Assign your desired layers by name. Done. Godot 4.x only. GDScript 2.0. Extended version with bitmask_to_names() inverse lookup for reading and debugging live collision state available at nullstateassets.itch.io. |
Set physics layer collision masks by name instead of bitmask arithmetic in Godot 4.x. Physics layer collision masks are set as bitmask integers. Bit 1 is layer 1, bit 2 is layer 2, and so on. To enable layers 1, 3, and 5 you write 1 + 4 + 16 = 21. You recalculate this by hand every time your layer assignments change. One wrong number and your raycasts silently hit the wrong things with no warning. This script reads a list of layer names from the Inspector and translates them into the correct bitmask at runtime. Set collision_layer_names to ["Player", "Projectile"] and collision_mask_names to ["Enemy", "World"] — the script does the math. Features: - Configure collision_layer and collision_mask by layer name array via Inspector - names_to_bitmask() public method for code-side use without a target node - Applies automatically on ready (configurable) - Works as a child node or attached directly to the physics node - Auto-detects parent physics node — no explicit assignment required - Debug output prints computed masks as 20-bit binary strings for visual verification - Compatible with CharacterBody2D, RayCast2D, Area2D, and any physics node - Zero dependencies — works in a blank project Add LayerStringHelper.gd as a child of your physics node. Set layer_names to match your project settings. Assign your desired layers by name. Done. Godot 4.x only. GDScript 2.0. Extended version with bitmask_to_names() inverse lookup for reading and debugging live collision state available at nullstateassets.itch.io. |
| Category | Scripts | Scripts |
| License | MIT | MIT |
| Repository Provider | GitHub | GitHub |
| Repository Url | https://github.com/NullState-Assets/LayerStringHelper | https://github.com/NullState-Assets/LayerStringHelper |
| Issues Url | https://github.com/NullState-Assets/LayerStringHelper/issues | https://github.com/NullState-Assets/LayerStringHelper/issues |
| Godot version | Godot 4.0 | Godot 4.0 |
| Version String | 1.0 | 1.0 |
| Download Commit | 6d005461bca34732961b3e8135e9ebd70daf310d | 6d005461bca34732961b3e8135e9ebd70daf310d |
| Download Url (Computed) | https://github.com/NullState-Assets/LayerStringHelper/archive/6d005461bca34732961b3e8135e9ebd70daf310d.zip | https://github.com/NullState-Assets/LayerStringHelper/archive/6d005461bca34732961b3e8135e9ebd70daf310d.zip |
| Icon Url |
https://raw.githubusercontent.com/NullState-Assets/LayerStringHelper/main/layerstringhelpericon.png
|
https://raw.githubusercontent.com/NullState-Assets/LayerStringHelper/main/layerstringhelpericon.png
|