unity-physicscore2d-stacking

Implements stable stacking, structural formations, and domino chain reactions in Unity PhysicsCore2D.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Building stable stacked structures in Unity's 2D physics engine is difficult: stacks collapse from misaligned centers of mass, insufficient friction, too few solver iterations, or sharp-cornered shapes. This Skill provides expert guidance and working C# examples for creating stable stacks, arches, card houses, pyramids, and domino chain reactions with the PhysicsCore2D (Unity.U2D.Physics) API.

Core Features & Use Cases

  • Stacking Stability Tuning: Guidance on friction, restitution, solver iterations, center of mass, and shape geometry (e.g., rounded box corners) to prevent collapse.
  • Structural Formations: Patterns for arches with keystones, towers, bridges, and precarious card houses, with ready-to-run example scripts.
  • Domino Chain Reactions: Setup for spacing, triggering via ApplyLinearImpulse, and multi-shelf alternating chains.
  • Use Case: A gameplay programmer building a destruction game can use the Pyramid.cs example (1830 dynamic boxes with slight corner radius) as a stress-tested template for large stable stacks, then tune friction and solver settings per the stability guidelines.

Quick Start

Ask the AI to create a stable pyramid stack of dynamic boxes in Unity PhysicsCore2D using rounded-corner box shapes and an enclosing chamber.

Frequently Asked Questions about unity-physicscore2d-stacking

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

FAQPage Schema
How do I make a stable stack of boxes in Unity 2D physics?

Stable box stacking in PhysicsCore2D requires high friction (0.5-0.8), low restitution (0.0-0.1), aligned centers of mass, and slightly rounded box corners via PolygonGeometry.CreateBox with a radius parameter. Increase solver iterations for tall stacks and build bottom-up with settling time.

How to trigger a domino chain reaction in Unity PhysicsCore2D?

Trigger a domino chain by calling ApplyLinearImpulse on the first domino with a small horizontal impulse applied near its top. Space dominos at roughly half their height, use friction around 0.6, and ensure each domino is a dynamic body resting stably on a static shelf.

Why does my 2D physics stack collapse immediately in Unity?

Stacks collapse from misaligned centers of mass, insufficient friction, too few solver iterations, sharp shape corners, or spawning the entire stack at once with overlapping bodies. Increase iterations to 8-16, raise friction, bevel polygon edges, and place bodies precisely without initial overlap.

Does PhysicsCore2D handle thin shapes like playing cards?

Yes, but thin shapes like cards (e.g., 0.001 thickness) are stress cases requiring high friction (around 0.7), precise angular placement, and high solver quality. The CardHouse example demonstrates a 5-story structure of tilted thin rectangles balanced with horizontal connector cards.

What are the performance limits for large stacked structures in Unity 2D physics?

Large stacks are expensive; the Pyramid example runs 1830 dynamic boxes as a stress test. Use sleeping for stable regions, static bodies for permanent structures, limit active collision pairs, and profile at your target stack size before shipping.