Share properties across multiple 2D Physics Core components
Create a definition object to configure properties such as gravity, friction, position, and shape.
Read time 3 minutesLast updated 13 days ago
To share properties across multiple physics objects, use the following:
- A definition asset to share a set of component properties, such as gravity or friction.
- A geometry asset to share a shape.
Definition assets and geometry assets are files in the Project window that store the shared values.
Share a set of area properties
Follow these steps:
-
Right-click in the Project window and select Create > 2D > Physics (Core).
-
Select the category and definition type you want to create. For example, select Area > Area Definition to create a shared set of properties for any Physics Area component.
-
Select the asset Unity creates in the Project window, then adjust its properties in thewindow.Inspector
?
-
In the Inspector window of any 2D Physics Core component that matches the definition type, drag the definition asset into the Definition Asset property, or select the picker (⊙).
To stop a component using a shared definition asset and revert it to using its own local properties, select Make Local.
Share a shape
To share a shape across multiple Area components, create a shared geometry asset. Follow these steps:
- Right-click in the Project window and select Create > 2D > Physics (Core) > Area.
- Select the shape you want to create, for example Circle Geometry.
- Select the asset Unity creates in the Project window, then adjust the properties in the Inspector window.
- In the Inspector window of any Physics Area component that matches the geometry type, drag the geometry asset into the Geometry Asset property, or select the picker (⊙).
For the full list of shapes, refer to Physics Pose and Physics Area components.
Save a set of existing properties
To create a definition asset or geometry asset with the current properties of a component, follow these steps:
- Select the GameObject with the component you want to create a definition from.
- In the Inspector window, next to the relevant Asset field, select Make Asset.
- Save the asset.
To stop a component using a shared asset and revert it to using its own local properties, select Make Local.
Change the default definitions
To change the default values of a component, follow these steps:
- Create and assign a Physics Core Settings 2D asset. For more information, refer to Configure global 2D Physics Core settings.
- In the window, select Physics Core 2D > Settings.Project Settings
?
- Configure the properties in the Default Definitions tab.
Unity uses the default values for components that don't have a definition asset assigned, and for a newly created definition asset.
For a full list of properties, refer to Physics Core 2D reference.