Add physics to a GameObject with 2D Physics Core
Create complex shapes with 2D Physics Core
Add physics to a sprite with 2D Physics Core
To add physics to a sprite GameObject and match the shape of the sprite for collisions, add a Physics Area Sprite component.
Note: This documentation is about using Pose, Area, and Constraint components. To use 2D physics in the Unity Editor using components like the Rigidbody 2D component, refer to 2D physics instead.
Add a Physics Area Sprite component
To add the component, follow these steps:
- Select a GameObject with a Sprite Renderer component.
- In the Inspector window, select Add Component, then select Physics 2D (Core) > Physics Pose.
- 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.
Additional resources
Add physics to a GameObject with 2D Physics Core
Create complex shapes with 2D Physics Core
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。