unity-physicscore2d-queries

Run single-shot Unity PhysicsCore2D queries for raycasts, overlaps, and shape casts.

730|105|Updated Mar 4, 2017
One-click install
npx skills add https://github.com/Unity-Technologies/PhysicsExamples2D --skill unity-physicscore2d-queries
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-physicscore2d-queries
Source: https://github.com/Unity-Technologies/PhysicsExamples2D/tree/main/.claude/skills/unity-physicscore2d-queries
Command: npx skills add https://github.com/Unity-Technologies/PhysicsExamples2D --skill unity-physicscore2d-queries

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Patterns for single-shot Unity PhysicsCore2D queries — raycasts (sight lines, ground checks, bullet hit-tests), overlap tests (trigger zones, AOE damage, ground checks), shape casts (projectile sweeps), distance/closest-point queries (AI awareness), and time-of-impact tests. Covers QueryFilter setup, layer masking, sorting hits, and the geometry-vs-world variants. For bulk/batched queries see unity-physicscore2d-batching. For full member API see unity-physicscore2d-queries-api.

Core Features & Use Cases

  • Pattern-driven queries for sight lines, overlaps, sweeps, distance checks, and time-of-impact to drive AI, gameplay, and effects.
  • Guidance on QueryFilter configuration, layer masks, hit sorting, and world-vs-geometry queries across common scenarios.
  • Real-world examples illustrate how to implement precise interactions, such as line-of-sight, area effects, and projectile sweeps.

Quick Start

Run a single-shot raycast from a given origin to a target and process the closest hit.

Frequently Asked Questions about unity-physicscore2d-queries

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

FAQPage Schema
How do I perform a Unity Physics2D raycast to check line of sight?

To perform a Unity Physics2D raycast for line of sight, you cast a ray from an origin to a target and process the closest hit. This single-shot query uses QueryFilter configuration to apply layer masking and sort hits for precise gameplay decisions.

What is the best way to detect overlap areas for AOE damage in Unity 2D?

The best way to detect overlap areas for AOE damage in Unity 2D is using single-shot overlap queries. These pattern-driven tests check for collider intersections within defined trigger zones, utilizing QueryFilter and layer masks to filter targets.

When should I use shape casts instead of raycasts for projectile sweeps?

You should use shape casts instead of raycasts for projectile sweeps when you need to detect collisions along a volume's path rather than a thin line. Shape casts sweep geometry through world space to find time-of-impact interactions.

How do I configure QueryFilter and layer masks for Physics2D distance queries?

You configure QueryFilter and layer masks for Physics2D distance queries by defining which layers to include or exclude before executing the query. This setup ensures AI awareness and closest-point calculations only process relevant geometry versus world variants.

Can I batch multiple Unity Physics2D queries together for better performance?

This Skill focuses on single-shot Unity Physics2D queries rather than batched execution. For bulk or batched queries that process multiple casts and overlaps simultaneously for performance, it references a separate batching Skill for those specific scaling needs.