Unity Physicscore2d Materials
Developmentunity-physicscore2d-materialsUnity Physicscore2d Materials is an Agent Skill for development published in the Unity-Technologies/PhysicsExamples2D repository on GitHub: a SKILL.md instruction file an AI agent can load to do this task.
Physics material properties including friction, bounciness/restitution, rolling resistance, and surface velocity (conveyor belts)
How to use this skill
Bring this guide into your coding agent with a prompt tailored to the tool you use.
- Open your project in Codex.
- Copy and paste the prompt below.
- Review files and risks before approving any action.
Inspect the Agent Skill at https://github.com/Unity-Technologies/PhysicsExamples2D/blob/HEAD/.claude/skills/unity-physicscore2d-materials/SKILL.md and all supporting files. Report provenance, permissions, scripts, dependencies, and security risks. Propose an exact installation into .agents/skills/unity-physicscore2d-materials, but wait for my approval before writing files or running scripts.
Copying this prompt does not install or run the skill. Review third-party files before use.
Unity PhysicsCore2D Materials Expert
You are now acting as a Unity PhysicsCore2D materials expert, specialized in physics material properties and surface behaviors.
Overview
PhysicsCore2D materials control how surfaces interact during collisions and contact. Key material properties include:
- Friction - Resistance to sliding motion
- Restitution (Bounciness) - Energy retained in collisions
- Rolling Resistance - Resistance to rolling motion
- Surface Velocity - Moving surfaces like conveyor belts
Repository Examples
Reference examples from the PhysicsExamples2D repository:
- Bounciness - https://github.com/Unity-Technologies/PhysicsExamples2D/blob/master/Sandbox/Assets/Examples/Bounciness.cs
- Friction - https://github.com/Unity-Technologies/PhysicsExamples2D/blob/master/Sandbox/Assets/Examples/Friction.cs
- RollingResistance - https://github.com/Unity-Technologies/PhysicsExamples2D/blob/master/Sandbox/Assets/Examples/RollingResistance.cs
- ConveyorBelt - https://github.com/Unity-Technologies/PhysicsExamples2D/blob/master/Sandbox/Assets/Examples/ConveyorBelt.cs
Material Properties
Friction
Friction is defined in PhysicsShapeDefinition:
- Controls sliding resistance between surfaces
- Value range typically 0.0 (frictionless) to 1.0 (high friction)
- Combined friction is calculated from both shapes in contact
- Static and dynamic friction use the same value
Restitution (Bounciness)
Restitution is defined in PhysicsShapeDefinition:
- Controls how much energy is retained after collision
- Value range 0.0 (no bounce) to 1.0 (perfectly elastic)
- Values above 1.0 add energy to the system
- Combined restitution is calculated from both shapes
Rolling Resistance
Rolling resistance prevents objects from rolling indefinitely:
- Simulates energy loss in rolling motion
- Useful for realistic ball and wheel behavior
- Applied as a damping force on angular velocity
Surface Velocity (Conveyor Belts)
Surface velocity makes a static surface act like a moving surface:
- Defined on static bodies to create conveyor belt effects
- Objects on the surface are pushed in the velocity direction
- Does not move the body itself, only affects contact behavior
Best Practices
- Use friction values between 0.3 and 0.8 for most realistic materials
- Restitution of 0.0 to 0.3 works well for most objects
- Very high restitution (>0.9) can cause instability
- Apply rolling resistance to prevent perpetual rolling
- Combine material properties carefully to avoid extreme behaviors
- Test material combinations to ensure desired interactions
Material Combination Rules
When two shapes collide, their material properties are combined:
- Friction typically uses multiplication or minimum of both values
- Restitution typically uses maximum of both values
- Exact combination rules depend on the physics engine settings
Related Skills
When users need information about:
- Shape properties - Use unity-physicscore2d-shapes-advanced
- Collision behavior - Use unity-physicscore2d-collision
- Surface forces - Use unity-physicscore2d-forces
Worked Examples
All examples below assume the standard PhysicsCore2D
OnEnable/OnDisablelifecycle. See the umbrella skillunity-physicscore2d, section "Creating and Destroy Physics Objects", for the canonical lifecycle pattern.
- examples/Friction.cs — friction sweep down a zig-zag of slopes, spawning bodies with progressively higher
surfaceMaterial.friction. - examples/Bounciness.cs — 40 dynamic bodies dropped onto a flat ground with
surfaceMaterial.bouncinessramped 0 → 1. - examples/RollingResistance.cs — 20 stacked slope chambers, each launching a ball with a higher
surfaceMaterial.rollingResistanceso you can see how rolling decays. - examples/ConveyorBelt.cs —
surfaceMaterial.tangentSpeedon a static box drags resting bodies horizontally without moving the box itself; tangent speed and angle are runtime-tunable.