Loading lessons...
2D Physics
2D Physics
Unity features a complete 2D physics simulation system that is separate from its 3D counterpart. All 2D physics classes and components end with a 2D suffix.
Rigidbody 2D
The Rigidbody 2D component puts the object under 2D physics control.
- Body Type:
- Dynamic: Affected by gravity and forces. Collides with all types. Used for characters and debris.
- Kinematic: Immune to forces/gravity. Moved manually via velocity or script. Collides only with Dynamic. Used for moving obstacles.
- Static: Position is fixed. Cannot be moved by physics. Used for ground and walls.
Colliders 2D
2D Colliders define physical collision boundaries:
- Box Collider 2D: Rectangular.
- Circle Collider 2D: Spherical boundary.
- Capsule Collider 2D: Capsule boundary.
- Polygon Collider 2D: Custom multi-sided shape (more expensive but accurate).
- Edge Collider 2D: A line or path of points (perfect for curved ground or slopes).
Physics Material 2D
A Physics Material 2D defines surface behavior:
- Friction: resistance to sliding.
- Bounciness: elasticity.
2D Physics Joint Components
Joints connect Rigidbody 2D components together:
- Hinge Joint 2D: Rotates around a pivot point (like a pendulum or swinging door).
- Distance Joint 2D: Keeps two objects at a fixed distance from each other.
- Slider Joint 2D: Restricts movement to a single axis (like a sliding drawer).
TL;DR
- All 2D physics components use the '2D' suffix (e.g. Rigidbody 2D).
- Body Types: Dynamic (forces), Kinematic (controlled), Static (fixed).
- Polygon and Edge Colliders support non-standard 2D shapes.
- 2D Joints connect rigidbodies with physical constraints.