We have redirected you to our new domain: store.godotengine.org. Please update your bookmarks!

Description
Changelog
Reviews

Godot Collision Presets

Turn messy fiddling with collision layers and masks into presets that you can easily apply to your nodes.

Overview

Godot already provides 32 collision layers, but managing them across large projects quickly becomes error-prone.

Collision Presets is a Godot 4 editor plugin designed to simplify physics management in 2D or 3D projects. Instead of manually memorizing bitmask integers or ticking boxes for every CollisionObject3D, you can define named presets (e.g., "Player", "Enemy", "Trigger") and apply them with a single click. The plugin keeps layers and masks in sync at runtime and exposes a small, clean API for code usage.

BEFORE AFTER
godot windows editor dev x86_64_n4lsLj8fD1 godot windows editor dev x86_64_DiAuice1ji-00 00 00 000-00 00 08 701

Minimal Examples

Once a preset is defined in the editor, you can apply it in your scripts using the generated constants:

# Setting a node's preset is supported in @tool mode. Uncomment to try it out!
# @tool
extends CharacterBody3D

func _ready():
    # Automatically apply the "Player" preset
    CollisionPresetsAPI.set_node_preset(self, CollisionPresets.Player)

Or check multiple presets' mask value for raycasting:

var query := PhysicsRayQueryParameters3D.create(from, to)

# Combine multiple presets into a single mask
var presets = [CollisionPresets.WorldStatic, CollisionPresets.Player]
query.collision_mask = CollisionPresetsAPI.get_combined_presets_layer(presets)

var result := space_state.intersect_ray(query)

Features

  • Inspector Integration: A custom UI appears directly in the CollisionObject inspector.
  • Default Collision Preset: Define a project-wide default preset automatically applied to any CollisionObject without a preset.
  • Metadata Based: The selected preset is stored in the node’s metadata. This makes it source control friendly and fully compatible with scene inheritance.
  • Centralized Database: All collision presets are saved automatically in a single .tres resource.
  • Type-Safe Constants: Automatically generates a CollisionPresets class with constants for all your preset names, enabling autocomplete and preventing typos.
  • Runtime Sync: An autoload ensures that any node with a preset assigned in the editor gets the correct layer and mask values when the game starts.
  • ID-Based Robustness: Presets use unique IDs internally, so renaming a preset won't break your existing node assignments.
  • Automatic Migration: Move the saving location of the presets database and the generated constants without breaking existing preset assignments.

Short Documentation

Project Settings (Physics/Collision Presets)
  • collision_presets_directory: Specifies the directory where the presets database and generated constants script are saved. Defaults to res://collision-presets/.
API Reference (CollisionPresetsAPI)
  • get_preset_layer(name) / get_preset_mask(name): Retrieves the raw integer values for a specific preset.
  • get_combined_presets_layer(names) / get_combined_presets_mask(names): Combines multiple presets into a single bitmask integer.
  • set_node_preset(node, preset_name): Sets a preset and updates the node's metadata (safe for @tool scripts).
  • get_node_preset(node): Returns the name of the preset currently assigned to a node.
  • get_preset_names(): Returns a list of all defined preset names.
Generated Constants (CollisionPresets)

The plugin generates a script at res://addons/collision_presets/preset_names.gd containing:

  • CollisionPresets.YOUR_PRESET_NAME: A string constant for each preset.
  • CollisionPresets.all(): Returns a PackedStringArray of all available preset names.

Installation

  1. Download or clone this repository into your project's addons/ folder.
  2. Go to Project Settings > Plugins and enable Collision Presets.
  3. The plugin will automatically:
    • Create a presets.tres file in the plugin folder.
    • Register a CollisionPresetRuntime autoload.
    • Generate the CollisionPresets constants script.
  4. Select any CollisionObject (StaticBody, CharacterBody, etc.) and look for the Preset dropdown in the Inspector.

Changelog for version 1.4

No changelog provided for this version.

Reviews (0)

Collision Presets has no reviews yet.

Login to write a review.