Add physics to a sprite with 2D Physics Core
Add a Physics Area Sprite component to derive physics shapes automatically from a sprite's physics outline.
Read time 1 minuteLast updated 16 days ago
To add physics to a sprite GameObject and match the shape of the sprite for collisions, add a Physics Area Sprite component.
Add a Physics Area Sprite component
To add the component, follow these steps:
- Select a GameObject with a Sprite Renderer component.
- In the window, select Add Component, then select Physics 2D (Core) > Physics Pose.Inspector
?
- Select Add Component again, then select Physics 2D (Core) > Physics Area Sprite.
Unlike other Physics Area components, the Physics Area Sprite component has no Geometry properties. Instead, the component copies the Custom Physics Outline of a sprite.
Edit the shape
To edit the shape the component uses, follow these steps:
- Select the sprite in the Project window.
- In the Inspector window, select Sprite Editor.
- In the dropdown, select Custom Physics Outline.
- Edit the shape. For more information, refer to Custom Physics Outline tab reference for the Sprite Editor window.
- To save your changes, select Apply.
If you add multiple shapes but the physics object has fewer shapes than you expect, check the Rejected Shape Count property in the Info section of the Physics Area Sprite component. If Unity rejected shapes, check the custom physics outline for unneeded extra points on a straight line, or points that are too close together.