0:00:01.229,0:00:04.401 The rigidbody 2D is a component that allows 0:00:04.401,0:00:07.135 a game object to be affected by 2D physics. 0:00:07.978,0:00:10.804 The game object must also have a collider 2D 0:00:10.804,0:00:13.608 component attached to interact with other game objects 0:00:13.608,0:00:15.221 using 2D physics. 0:00:16.067,0:00:18.925 A rigidbody 2D is required when working with 0:00:18.925,0:00:20.925 specialised 2D physics components 0:00:20.925,0:00:22.925 such as 2D joints. 0:00:23.922,0:00:27.036 The rigidbody 2D is also used to define important 0:00:27.036,0:00:29.230 physical properties about the game object, 0:00:29.230,0:00:32.339 such as it's mass, linear and angular drag, 0:00:32.339,0:00:34.781 gravity scale and other properties. 0:00:35.640,0:00:38.491 It is worth noting that unlike 3D physics 0:00:38.491,0:00:41.398 the rigidbody 2D has a gravity scale 0:00:41.398,0:00:43.398 which allows gravity to be set on a 0:00:43.398,0:00:45.398 per-game-object basis. 0:00:46.271,0:00:48.465 In this scene the prop_ammo_crate 0:00:48.465,0:00:50.548 is a simple game object with a sprite 0:00:50.548,0:00:52.963 renderer to hold and render the sprite. 0:00:55.010,0:00:58.405 Enter play mode, and nothing happens. 0:00:59.872,0:01:02.834 2D physics behaviour can be added to the ammo crate 0:01:02.834,0:01:05.469 by attaching a rigidbody 2D 0:01:05.469,0:01:12.463 with Add Component - Physics 2D - Rigidbody 2D. 0:01:13.833,0:01:15.833 It is worth noting that there are other ways to 0:01:15.833,0:01:17.833 attach a component to a game object. 0:01:19.535,0:01:21.535 For more information on components and 0:01:21.535,0:01:23.151 how to add them to game objects 0:01:23.151,0:01:25.473 please see the information linked below. 0:01:27.074,0:01:29.842 When in play mode, the ammo crate now falls 0:01:29.842,0:01:32.108 under the influence of gravity. 0:01:32.108,0:01:34.314 But it does not collide with the space ship. 0:01:35.616,0:01:39.205 To interact with other game objects using 2D physics 0:01:39.205,0:01:43.100 all game objects involved need collider 2d components 0:01:43.100,0:01:46.959 and at least 1 needs to have a rigidbody 2D attached. 0:01:47.873,0:01:50.856 The space ship already has a 2D collider. 0:01:50.856,0:01:53.022 A collider 2D component can be added 0:01:53.022,0:01:55.161 to the ammo crate by selecting 0:01:55.161,0:02:01.349 Add Component - Physics 2D - Box Collider. 0:02:02.650,0:02:04.871 The size of the 2D collider will automatically 0:02:04.871,0:02:06.871 match the size of the sprite. 0:02:08.075,0:02:10.075 In this case the collider needs to be adjusted 0:02:10.075,0:02:12.605 to match the image of the ammo box. 0:02:17.298,0:02:19.159 Now, when in play mode, 0:02:19.659,0:02:22.385 the ammo crate collides with, and comes to rest on 0:02:22.385,0:02:24.026 the top of the space ship. 0:02:24.788,0:02:26.788 For more information on 2D colliders 0:02:26.788,0:02:29.244 please see the information linked below. 0:02:31.015,0:02:33.683 The rigidbody 2D component not only allows a 0:02:33.683,0:02:36.315 game object to be affected by 2D physics, 0:02:36.315,0:02:38.815 it is used to define important physical 0:02:38.815,0:02:40.815 properties about that game object. 0:02:42.669,0:02:45.589 Mass is the mass of the rigidbody 2D. 0:02:46.006,0:02:48.090 2D rigidbodies with higher mass, 0:02:48.090,0:02:49.866 like those in the real world, 0:02:49.866,0:02:52.378 take more force to move and will have greater affect 0:02:52.378,0:02:55.074 when colliding with other 2D rigidbodies. 0:02:55.955,0:02:57.845 In this first case the ammo crate 0:02:57.845,0:02:59.845 and the asteroid have the same mass. 0:03:05.704,0:03:07.969 When the mass is changed on the asteroid 0:03:08.897,0:03:10.897 the interaction between the two game objects 0:03:10.897,0:03:12.897 is significantly different. 0:03:19.253,0:03:21.475 Linear and Angular drag affect 0:03:21.475,0:03:24.029 the velocity of 2D rigidbodies. 0:03:24.969,0:03:28.211 Think of this as something similar to air resistance. 0:03:29.098,0:03:31.404 Linear drag will slow the speed, or velocity 0:03:31.404,0:03:33.404 of the rigidbody 2D. 0:03:39.899,0:03:42.270 And angular drag will slow it's rotation 0:03:42.270,0:03:44.270 or angular velocity. 0:04:00.874,0:04:05.008 Gravity Scale controls how gravity affects the rigidbody 2D. 0:04:05.646,0:04:08.351 Unlike changing the global value of gravity 0:04:08.351,0:04:10.351 gravity scale allows for precise 0:04:10.351,0:04:12.765 control on a per-game-object basis. 0:04:13.928,0:04:15.928 When in play mode the ammo crate 0:04:15.928,0:04:18.218 falls under the influence of gravity. 0:04:19.243,0:04:21.243 Lower the gravity scale value 0:04:24.008,0:04:26.008 and the game object falls more slowly. 0:04:26.798,0:04:29.452 To disable gravity set this value to 0. 0:04:31.121,0:04:33.411 When Fixed Angle is selected the rigidbody 0:04:33.411,0:04:35.991 2D will respond to 2D physics forces 0:04:35.991,0:04:37.991 but it will not rotate. 0:04:37.991,0:04:40.559 Under normal conditions the asteroid will fall, 0:04:40.559,0:04:43.277 collide with the ammo box and roll away. 0:04:44.758,0:04:47.258 When Fixed Angle is selected 0:04:47.258,0:04:50.866 the asteroid will continue to react to physical forces, 0:04:51.808,0:04:53.419 such as the collision. 0:04:53.990,0:04:55.990 But it will not rotate. 0:04:58.230,0:05:00.313 When Is Kinematic is selected 0:05:00.313,0:05:02.823 the rigidbody 2D is considered to be a 0:05:02.823,0:05:04.823 kinematic rigidbody 2D 0:05:04.823,0:05:07.505 and is not affected by 2D physics forces, 0:05:07.505,0:05:09.505 including gravity and collisions. 0:05:10.516,0:05:12.516 This is typically done when moving a game object 0:05:12.516,0:05:14.516 with a 2D collider without using 0:05:14.516,0:05:16.516 physics or physics forces. 0:05:17.196,0:05:20.053 For example, when creating a moving platform. 0:05:20.053,0:05:22.053 The platform could be controlled by a 0:05:22.053,0:05:24.053 script or animation 0:05:24.053,0:05:26.219 and be moved by it's transform, 0:05:26.219,0:05:28.219 not by physics forces. 0:05:28.650,0:05:30.650 However, the platform needs to interact 0:05:30.650,0:05:32.650 with other 2D game objects. 0:05:33.150,0:05:35.426 So the platform needs a 2D collider 0:05:35.426,0:05:37.136 attached as well. 0:05:38.036,0:05:40.426 This means there is now a moving game object 0:05:40.426,0:05:42.426 with a collider 2D attached. 0:05:43.658,0:05:47.018 When moving a collider 2D while the game is playing 0:05:47.018,0:05:49.824 it is highly recommended that a rigidbody 2D 0:05:49.824,0:05:51.479 be attached as well. 0:05:52.241,0:05:54.419 Yet we don't want this platform to react 0:05:54.419,0:05:56.419 to physics forces. 0:05:57.002,0:05:59.002 In this case, the rigidbody will be set 0:05:59.002,0:06:01.002 to Is Kinematic. 0:06:01.861,0:06:03.861 This platform is moved via scripting 0:06:03.861,0:06:05.861 with a 2D collider attached. 0:06:16.678,0:06:18.373 The Interpolate settings can help smooth 0:06:18.373,0:06:20.373 movement of a game object. 0:06:20.373,0:06:22.373 If a game object appears to jitter when 0:06:22.373,0:06:24.937 being moved by it's rigidbody 2D 0:06:24.937,0:06:26.937 use the Interpolate settings to help 0:06:26.937,0:06:28.937 smooth it's transform movement. 0:06:29.796,0:06:31.796 The Interpolate setting will smooth the 0:06:31.796,0:06:33.601 movement based on the game object's 0:06:33.601,0:06:35.601 position in the previous frame. 0:06:36.902,0:06:38.902 And the Extrapolate setting will use the 0:06:38.902,0:06:40.902 predicted position in the next frame. 0:06:42.590,0:06:44.590 Sleeping Mode controls how the rigidbody 0:06:44.590,0:06:47.322 will sleep to save processing time. 0:06:47.794,0:06:50.280 Never Sleep will disable sleeping 0:06:50.780,0:06:53.280 Start Awake will make sure the rigidbody 2D 0:06:53.280,0:06:56.176 is awake when instantiated. 0:06:56.176,0:06:58.176 Start Asleep will initially set the 0:06:58.176,0:07:00.176 rigidbody 2D to sleep 0:07:00.176,0:07:02.590 but it can be woken by collisions. 0:07:03.988,0:07:05.864 For more information on sleeping 0:07:05.864,0:07:08.351 please see the information linked below. 0:07:09.690,0:07:11.690 The collision detection settings control 0:07:11.690,0:07:13.690 the type of collision detection used 0:07:13.690,0:07:15.690 when a rigidbody 2D. 0:07:16.673,0:07:18.673 The default is Discrete 0:07:18.673,0:07:20.673 and it is best to use discrete unless 0:07:20.673,0:07:22.506 there are problems. 0:07:22.506,0:07:24.939 In this case collisions are registered if 0:07:24.939,0:07:27.232 the game object's 2D collider 0:07:27.232,0:07:30.566 is in contact with another during a physics update. 0:07:31.522,0:07:34.189 Continuous is for fast moving game objects 0:07:34.189,0:07:36.189 and collisions are registered if the game object 0:07:36.189,0:07:40.048 appears to have collided with another between updates. 0:07:42.164,0:07:45.944 For more information on physics 2D and the rigidbody 2D 0:07:45.944,0:07:48.522 please see the information linked below.