wave5-collision-filter-layer-masking

Implement Unity DOTS collision-layer masking with CollisionFilter bitmasks.

6|Updated Apr 2, 2026
One-click install
npx skills add https://github.com/dyCuong03/unity-agent-team --skill wave5-collision-filter-layer-masking
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: wave5-collision-filter-layer-masking
Source: https://github.com/dyCuong03/unity-agent-team/tree/main/.claude/skills/unity-dots/wave5-collision-filter-layer-masking
Command: npx skills add https://github.com/dyCuong03/unity-agent-team --skill wave5-collision-filter-layer-masking

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill helps you control which physics bodies collide with each other and which spatial queries detect, preventing unwanted contacts and false-positive raycasts/overlaps that waste CPU time.

Core Features & Use Cases

  • Collision pair filtering: Use CollisionFilter.BelongsTo and CollisionFilter.CollidesWith bitmasks so only intended body pairs interact.
  • Query-time layer targeting: Apply the same filtering to rays/queries so they hit only specific layers (e.g., projectiles hitting ground and enemies, not allies).
  • Performance optimization: Reduce broadphase candidate pairs and narrowphase evaluations in dense scenes by tightening filters instead of using defaults.

Quick Start

Tell your AI to update your Unity Physics colliders and raycast/query filters so BelongsTo is set on bodies (who they are) and CollidesWith is set on queries/bodies (who they can hit), using shared 1u << layerIndex constants and aligning both sides of the rule.

Frequently Asked Questions about wave5-collision-filter-layer-masking

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I filter Unity DOTS physics collision layers to stop unwanted raycast hits?

Filter Unity DOTS physics collision layers by applying symmetric bitmasks using CollisionFilter.BelongsTo and CollisionFilter.CollidesWith. This ensures raycasts and spatial queries only hit intended layers, preventing false positives and incorrect body interactions.

Why does my Unity Physics spatial query return false positives in high-density simulations?

Spatial queries return false positives in high-density Unity Physics simulations when default filters are used. Tightening collision filters with specific BelongsTo and CollidesWith bitmasks reduces broadphase candidate pairs and eliminates inaccurate query results.

What is the best way to optimize Unity DOTS physics performance by reducing collision pairs?

Optimize Unity DOTS physics performance by tightening CollisionFilter bitmasks instead of using defaults. Precise BelongsTo and CollidesWith settings reduce broadphase candidate pairs and narrowphase evaluations in dense scenes, saving CPU time.

How do I set up CollisionFilter BelongsTo and CollidesWith bitmasks for Unity Physics colliders?

Set up CollisionFilter bitmasks by assigning BelongsTo on colliders to define their layer and CollidesWith on queries to define target layers. Use shared 1u << layerIndex constants to align both sides of the filtering rule.

Does Unity DOTS GroupIndex affect collision filter masking for spatial queries?

GroupIndex affects collision filter masking in Unity DOTS and must be handled intentionally. When configuring BelongsTo and CollidesWith bitmasks, GroupIndex overrides standard layer logic to maintain correct gameplay semantics during spatial queries.

Can I use collision layer masking to prevent friendly fire in Unity DOTS projectile raycasts?

Use collision layer masking to prevent friendly fire by setting projectile raycasts to CollidesWith enemy and ground layers only. Assigning BelongsTo layers correctly ensures projectiles bypass allies, reducing physics noise and wasted query evaluations.