The Box Collider 2D component is a Collider for use with 2D physics. Its shape is a rectangle with a defined position, width and height in the local coordinate space of a Sprite. Note that the rectangle is axis-aligned - that is, its edges are parallel to the X or Y axes of local space.
Property | Function |
---|---|
Density | Changing the density here affects the mass of the GameObject’s associated Rigidbody 2D. Set the value to 0 and its associated Rigidbody 2D ignores the Collider 2D for all mass calculations, including center of mass calculations. Note that this option is only available if you have selected Use Auto Mass in an associated Rigidbody 2D component. |
Material | A physics Material that determines properties of collisions, such as friction and bounce. |
Is Trigger | Check this box if you want the Box Collider 2D to behave as a trigger. |
Used by Effector | Check this box if you want the Box Collider 2D to be used by an attached Effector 2D component. |
Used by Composite | Tick this checkbox if you want this Collider to be used by an attached Composite Collider 2D. When you enable Used by Composite, other properties disappear from the Box Collider 2D component, because they are now controlled by the attached Composite Collider 2D. The properties that disappear from the Box Collider 2D are Density, Material, Is Trigger, Used By Effector, and Edge Radius. |
Auto Tiling | Tick this checkbox if the Sprite Renderer component for the selected Sprite has the Draw Mode set to Tiled. This enables automatic updates to the shape of the Collider 2D, meaning that the shape is automatically readjusted when the Sprite’s dimensions change. If you don’t enable Auto Tiling, the Collider 2D geometry doesn’t automatically repeat. |
Offset | Set the local offset of the Collider 2D geometry. |
Size | Set the size of the box in local space units. |
Edge Radius | Controls a radius around edges, so that vertices are circular. This results in a larger Collider 2D with rounded convex corners. The default value for this setting is 0 (no radius). |
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker at issuetracker.unity3d.com.
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thanks for helping to make the Unity documentation better!