Videogames Development – Unity – How to add Physics 2D

ADD PHYSICS

Setup the Physics 2D engine

MAIN TOP MENU> Edit> Project Settings> Physics 2D> Inspector> Gravity

Create a Sphere over a Box, the Sphere will fall and will collide overe the box

1. Hierarchy> select Sphere
2. MAIN TOP MENU> Component> Physics 2D> Rigidbody 2D
3. Hierarchy> select Sphere> Inspector> Rigidbody 2D> setup parameters
4. Hierarchy> select Sphere> Inspector> ‘Add Component Button’> Physics 2D> Polygon Collider
5. Hierarchy> select Sphere> Inspector> Polygon Collider 2D> setup parameters

6. TOP CENTER> click over ‘Play’ button, the Sphere will fall
7. TOP CENTER> click over ‘Play’ button, to stop simulation

8. Hierarchy> select Box
9. MAIN TOP MENU> Component> Physics 2D> Polygon Collider 2D
10. Hierarchy> select Sphere> Inspector> Polygon Collider 2D> setup parameters
11. Viewport> MAIUSC+LMB click over the wireframe of the Polygon Collider to change it

12. MAIN TOP MENu> Assets> Create> Physics 2D Material
13. ‘Assets’ window> select New Physics2D Material> Inspector> setup Friction / Bounciness
> Bounciness >

14. Hierarchy> select Sphere> Polygon Collider 2D> Material> New Physics2D Material
15. Hierarchy> select Box> Polygon Collider 2D> Material> New Physics2D Material

16. TOP CENTER> click over ‘Play’ button, now there is collision
17. TOP CENTER> click over ‘Play’ button, to stop simulation