unity-physicscore2d-events-api

Documents Unity 6000.5 PhysicsCore2D Events and Callbacks API types, members, and signatures.

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

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Unity 6000.5's PhysicsCore2D API post-dates most AI training data, so code assistants often hallucinate member names or signatures when working with its Events and Callbacks system. This Skill provides an authoritative, auto-generated API reference so generated code matches the real API surface.

Core Features & Use Cases

  • Complete API Reference: Lists every nested type, property, method signature, parameter, and return value for PhysicsCallbacks and PhysicsEvents in Unity.U2D.Physics.
  • Callback Interface Documentation: Covers IContactCallback, ITriggerCallback, IPreSolveCallback, IContactFilterCallback, IBodyUpdateCallback, IJointThresholdCallback, and transform write callbacks, including threading and deadlock warnings.
  • Event Struct Details: Documents ContactBeginEvent, ContactEndEvent, TriggerBeginEvent, ContactHitEvent, PreSolveEvent, and related event payloads.
  • Use Case: When implementing a contact callback in a Unity 6000.5 project, consult this Skill to get the exact OnContactBegin2D(PhysicsEvents.ContactBeginEvent) signature and the requirement to dispose returned callback targets.

Quick Start

Ask the AI to write a Unity 6000.5 PhysicsCore2D script that implements a contact begin callback using the correct interface and event types.

Frequently Asked Questions about unity-physicscore2d-events-api

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

FAQPage Schema
How do I implement a contact callback in Unity PhysicsCore2D?

Implement the PhysicsCallbacks.IContactCallback interface, which provides OnContactBegin2D and OnContactEnd2D methods receiving PhysicsEvents.ContactBeginEvent and ContactEndEvent. These callbacks run on the main thread after the simulation finishes.

What is the difference between PhysicsCallbacks and PhysicsEvents in Unity 6000.5?

PhysicsCallbacks contains the callback interfaces and target containers, while PhysicsEvents defines the event structs like ContactBeginEvent and TriggerEndEvent plus static events such as PreSimulate and PostSimulate. Both live in the Unity.U2D.Physics namespace.

Is the PhysicsCore2D contact filter callback thread-safe?

No, IContactFilterCallback and IPreSolveCallback run during the simulation step and can be called from any thread, so implementations must be thread-safe. Write operations on the world cause deadlocks; only simple reads on bodies or shapes are safe.

Why do PhysicsCore2D callback targets need Dispose called?

ContactCallbackTargets, TriggerCallbackTargets, BodyUpdateCallbackTargets, and JointThresholdCallbackTargets allocate native memory when returned. Failing to call Dispose on them causes memory leaks.

Does this API reference cover the old Unity Physics2D components?

No, it covers only the newer PhysicsCore2D API (Unity.U2D.Physics) in Unity 6000.5, generated from UnityEngine.PhysicsCore2DModule.xml. The legacy Physics2D component API is a separate system.