unity-2d-cameras
Unity 2D cameras — Cinemachine 2D (CinemachineCamera, Confiner 2D, Framing Transposer, Group Composer), Pixel Perfect Camera, parallax via cameras vs sprites, screen shake, target groups, virtual camera priorities. USE WHEN: setting up smooth 2D camera follow, framing rules, level-bound confiners, dynamic groups (multiple players), screen shake, pixel-perfect rendering of camera motion. DO NOT USE FOR: 3D Cinemachine (covered separately under unity-rendering / unity-physics-anim); UI cameras (use `unity-input-ui`).
What this skill does
# Unity 2D Cameras
## Cinemachine basics (2D context)
`com.unity.cinemachine` 3.x ships:
- **CinemachineBrain** on your Main Camera — drives blends.
- **CinemachineCamera** (CmCamera in Cinemachine 3) — virtual camera with priority.
- The CmCamera with the highest priority controls the actual camera, with smooth blends in between.
Default 2D follow setup:
```
Main Camera (Orthographic) + CinemachineBrain
└── PlayerFollow (CinemachineCamera)
Lens > Orthographic + size = 5
Follow → Player transform
Body → Position Composer (formerly Framing Transposer)
Tracked Object Offset (0, 1, 0) (slight upward look)
Damping X 0.3, Y 0.3
Dead Zone Width 0.1, Height 0.2
Soft Zone Width 0.5, Height 0.5
```
Screen position breakdown:
- **Dead Zone** — target inside this rectangle → camera doesn't move.
- **Soft Zone** — target moving here → camera eases to recenter.
- **Outside Soft Zone** — camera tracks immediately.
## Confiner 2D — keep camera inside level bounds
Add `CinemachineConfiner2D` extension to the CmCamera; assign a **PolygonCollider2D** (or CompositeCollider2D) representing the playable area. Camera will never reveal beyond the polygon.
For multi-room games, swap the bounding shape on room change.
## Group framing — multiplayer
```
GroupCenter (CinemachineCamera + GroupComposer body)
Targets: TargetGroup with [Player1, Player2, Player3]
```
Group composer keeps all members on screen, zooming in/out as they spread.
## Pixel Perfect Camera + Cinemachine
Pixel snapping needs camera position quantized to integer pixel multiples. Cinemachine 3 + Pixel Perfect Camera require:
```
On the Cinemachine Brain GameObject (Main Camera):
Add CinemachinePixelPerfect extension at the brain level (Cinemachine 3)
OR
Use CinemachineConfiner2D + Pixel Perfect Camera component on Main Camera (older approach)
```
Without it, camera follow jitters at sub-pixel level when the target moves slowly.
## Parallax — two approaches
### A. Multiple cameras
Each background layer has its own camera with a different orthographic size or stacked render. Heavier but pixel-perfect.
### B. Sprite-based parallax (lighter — recommended)
```csharp
public class ParallaxLayer : MonoBehaviour {
[SerializeField] private Transform cam;
[SerializeField, Range(0f, 1f)] private float multiplier = 0.5f;
private Vector3 _start;
private Vector3 _camStart;
void Start() { _start = transform.position; _camStart = cam.position; }
void LateUpdate() {
var delta = cam.position - _camStart;
transform.position = _start + new Vector3(delta.x * multiplier, delta.y * multiplier, 0);
}
}
```
Multiplier 0 = sticks to player, 1 = world-locked. Stack layers from `0.1` (far sky) to `0.9` (near foreground).
## Screen shake (Cinemachine Impulse)
```csharp
[SerializeField] private CinemachineImpulseSource impulse;
public void OnExplosion() => impulse.GenerateImpulseAtPositionWithVelocity(
transform.position, Random.insideUnitSphere * 1.5f);
```
CmCamera has a `CinemachineImpulseListener` extension → reacts to all impulses in range. Tune by **signal asset** (frequency, amplitude, duration).
## Anti-patterns
| Anti-pattern | Fix |
|---|---|
| Hard-coded camera follow on Update | Cinemachine CmCamera + Position Composer |
| Manual clamping per scene | Confiner 2D |
| Pixel jitter on slow camera moves | Pixel Perfect + CinemachinePixelPerfect extension |
| Per-frame `Camera.main` refs | Cache `Camera.main` once OR get from CinemachineBrain |
| Many parallax layers each with their own camera | Sprite-based parallax LateUpdate |
| Screen shake by writing camera position | Use Impulse Source/Listener |
## Production checklist
- [ ] Main Camera has CinemachineBrain
- [ ] One CmCamera per gameplay state (gameplay, dialogue, cinematic)
- [ ] Confiner 2D assigned per playable area
- [ ] Pixel Perfect (if pixel art) integrated with Cinemachine
- [ ] Parallax layers configured
- [ ] Screen shake via Impulse — no manual position writes
- [ ] Camera priorities documented
Related in Design
contribute
IncludedLocal-only OSS contribution command center. Auto-refreshes the user's in-flight PR and issue state on invoke so conversations start with full context — no need to brief Claude on what's in flight. Helps the user find issues to contribute to on GitHub, builds per-repo dossiers of what each upstream expects (CLA, DCO, branch convention, AI policy, draft-first, review bots, issue templates), runs deterministic gates before any external action so AI-assisted contributions don't reach maintainers as slop. State is markdown-only: candidate files at ~/.contribute-system/candidates/, repo dossiers at ~/.contribute-system/research/, append-only event log at ~/.contribute-system/log.jsonl. No database, no cloud calls. Use when the user asks about their PRs / issues / contributions, wants to find new work to take on, claim an issue, build/refresh a repo's dossier, or draft a Design Issue or PR. Trigger with "/contribute", "what's my PR status", "find a contribution", "claim issue X", "draft a Design Issue for Y", "refresh dossier for Z".
architectural-analysis
IncludedUser-triggered deep architectural analysis of a codebase or scoped subtree across eight modes — information architecture, data flow, integration points, UI surfaces, interaction patterns, data model, control flow, and failure modes. This skill should be used when the user asks to "diagram this codebase," "map the architecture," "show the data flow," "give me an ERD," "trace control flow," "find the integration points," "verify the layout pattern," "audit the UX architecture," or any similar request whose primary deliverable is mermaid diagrams plus cited reports under docs/architecture/. Dispatches haiku/sonnet sub-agents in parallel for per-mode exploration, then verifies every citation mechanically before any node lands in a diagram. Not for one-off prose explanations of code (use code-explanation) or for high-level system design from scratch (use system-design).
mcp
IncludedModel Context Protocol (MCP) server development and tool management. Languages: Python, TypeScript. Capabilities: build MCP servers, integrate external APIs, discover/execute MCP tools, manage multi-server configs, design agent-centric tools. Actions: create, build, integrate, discover, execute, configure MCP servers/tools. Keywords: MCP, Model Context Protocol, MCP server, MCP tool, stdio transport, SSE transport, tool discovery, resource provider, prompt template, external API integration, Gemini CLI MCP, Claude MCP, agent tools, tool execution, server config. Use when: building MCP servers, integrating external APIs as MCP tools, discovering available MCP tools, executing MCP capabilities, configuring multi-server setups, designing tools for AI agents.
react-native-skia
IncludedDesign, build, debug, and optimise high-polish animated graphics in React Native or Expo using @shopify/react-native-skia, Reanimated, and Gesture Handler. Use when the user wants canvas-driven UI, shaders, paths, rich text, image filters, sprite fields, Skottie, video frames, snapshots, web CanvasKit setup, or performance tuning for custom motion-heavy elements such as loaders, hero art, cards, charts, progress indicators, particle systems, or gesture-driven surfaces. Also use when the user asks for fluid, glow, glass, blob, parallax, 60fps/120fps, or GPU-friendly animated effects in React Native, even if they do not explicitly say "Skia". Do not use for ordinary form/layout work with standard views.
plaid
IncludedProduct Led AI Development — guides founders from idea to launched product. Six capabilities: Idea (discover a product idea), Validate (pressure-test the idea against fatal flaws, problem reality, competition, and 2-week MVP feasibility), Plan (vision intake + document generation), Design (translate image references into a design.md spec), Launch (go-to-market strategy), and Build (roadmap execution). Use when someone says "PLAID", "plaid idea", "help me find an idea", "product idea", "idea from my business", "idea from my expertise", "plaid validate", "validate my idea", "pressure-test", "is this idea good", "find fatal flaws", "validate the problem", "plan a product", "define my vision", "generate a PRD", "product strategy", "plaid design", "design from image", "translate image to design", "create design.md", "extract design tokens", "plaid launch", "go-to-market", "launch plan", "GTM strategy", "launch playbook", "plaid build", "build the app", "start building", or "execute the roadmap".
nextjs-framer-motion-animations
IncludedAdds production-safe Motion for React or Framer Motion animations to Next.js apps, including reveal, hover and tap micro-interactions, whileInView, stagger, AnimatePresence, layout and layoutId transitions, reorder, scroll-linked UI, and lightweight route-content transitions. Use when the user asks to add, refactor, or debug Motion or Framer Motion in App Router or Pages Router codebases, especially around server/client boundaries, reduced motion, LazyMotion, bundle size, hydration, or route transitions. Avoid for GSAP-style timelines, WebGL or 3D scenes, heavy scroll storytelling, or CSS-only effects unless Motion is explicitly requested.