unity-physics

Perform raycasts, overlap checks, and gravity configuration in Unity gameplay scripts.

1|Updated Feb 22, 2024
One-click install
npx skills add https://github.com/Stardust-liu/EDC_Framework --skill unity-physics-stardust-liu
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: unity-physics
Source: https://github.com/Stardust-liu/EDC_Framework/tree/main/Assets/AI/Unity-Skills-1.5.5/unity-skills/skills/physics
Command: npx skills add https://github.com/Stardust-liu/EDC_Framework --skill unity-physics-stardust-liu

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Unity developers need to perform common physics queries (raycasts, overlap checks) and adjust gravity, all within gameplay scripting. This unit provides ready-to-use patterns and function outlines to streamline physics-related tasks.

Core Features & Use Cases

  • Raycast: Cast a ray and capture hit information for obstacle detection and bullet/skill trajectories.
  • Overlap: Check for nearby colliders within a radius to trigger area-based events.
  • Gravity: Get or set global gravity to control character movement and physics behavior.
  • Use Case: Use this skill when implementing player shooting, enemy AI sensing, or environmental interactions that depend on physics queries.

Quick Start

Use the unity-physics skill to perform a raycast from the player's position and process the hit result.

Frequently Asked Questions about unity-physics

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

FAQPage Schema
How do I perform a raycast in Unity to detect obstacles?

To perform a raycast in Unity, cast a ray from a specified origin and capture the hit information to detect obstacles along its path. This allows gameplay scripts to process bullet trajectories or object interactions.

How do I check for nearby colliders within a specific radius in Unity?

To check for nearby colliders in Unity, perform a sphere overlap query to identify all colliders within a defined radius. This overlap check triggers area-based events and detects entities near a specific point.

How do I get or set global gravity in Unity scripts?

To get or set global gravity in Unity, read or modify the global gravity values within your gameplay scripts. This controls character movement and physics behavior dynamically during real-time gameplay.

Can I use Unity physics queries for enemy AI sensing?

Yes, you can use Unity physics queries for enemy AI sensing by utilizing raycasts and overlap checks. These operations detect players and environmental objects, allowing AI to adapt collision detection to play conditions.

What is the best way to implement area-based event triggers in Unity?

The best way to implement area-based event triggers in Unity is by using sphere overlap queries to scan for colliders within a radius. This checks for nearby objects and triggers events when entities enter the zone.

Why are my Unity raycasts not returning expected hit information?

If your Unity raycasts are not returning expected hit information, verify that the parameterized raycast results correctly capture collision data. Ensure colliders are enabled and ray parameters match your gameplay script conditions.