Rigidbody components in Unity

Transcript

English (Auto-generated)

Hi everyone in this cast will be talking about rigid bodies. So a rigid body immunity treaty is a component that when added to any game object will allow it to interact with fundamental physics behavior. For example this means forces like gravity acceleration and so on. So a game object that has a rigid body component will be treated like a real world object in the physical world which is affected by gravity, mass acceleration so on and so forth. So rigid body. Since it's acting any game object which has a rigid body component will be used in interactions like collisions. So for example let's suppose you're making a target shooting game right? So you need to make sure that your arrow collides with the target. Now for example let's suppose we have a game object so we have a cube object here in our scene and when I play you notice that it doesn't fall to the ground or let's say this plane when I click on place so it's not reacting to gravity like a real world object would. Right? So if it was that means it would follow the law of gravity have mass and this cube would feel heavy when it's pushed or pulled. So let's um add a rigid body component to this cube. And the way to do that is in the inspector window you want to go click on, add component and then rigid body. So rigid body is for three D. Objects and then rigid body two D. Is for two D. Games. So since this is three D. I'll just click on rigid body now out here you can see that the component has many properties. So let's go over some of the common component properties of the rigid body component which are likely to use. So number one is mass. Now the mass of an object is in kilograms or kgs and it's similar to weight and affects how much the object will move when other forces act on it. Right now out here you can see I'm just gonna let it be one drag. I'm going to let that be as is. And important to notice out here is I have used gravity so when you use gravity is checkmark it means that this cube will react to gravity. So let's click on play and there you go. So it falls to the ground. Now what if I unclipped on use gravity and out here you see that it's pretty much acting like the way it would if it didn't have a rigid body component attached to it in the first place. Okay so now let's take a look at another scene that I've got here which is seen to so let's save this and navigate to our other scene. Okay so this is what let's go to the scene here. Right so this is what my scene is like right now right and out here you can see that both the cubes have the same way. So they're not they're just swing back and forth. Right? So they're both one kg each. So cube A is a one and then be Is one as well. Right? So when both the cubes are of the same weight that is they have a mass of one kg. Um And they fall. The plank doesn't sway either way. Now let's make the red cube a bit heavier. So let's make it have a mass of five and let's see what happens now. So I've changed the mass property the value of the mass property to five. And clicking on play. There you go. So you can see that it's pretty dramatic. And the right when the right cue praise more. So it's five kgs. Then the left Cube which is one KK. The plant will sway more to the right side since it has more weight on that side. Okay and we already talked about the use gravity. So if I uncheck Mark use gravity for the right hand side cube, which is the this red cube, you'll notice that it will not react to gravity. Right? So basically now what's happening is flew off into space. Right so we can try that again. So clicking on play. Um there you go. So it doesn't fall it just goes off into space. Right? Okay now let's talk about the scan dramatic property here. Right now this property indicates that the game object is not affected by physics. That means it's not going to be affected by gravity or any other physical forces. However the game object does affect, it's a surrounding objects. Right? So for example, now let's just check Mark is Kinnah Matic. Again, for the red right hand side cube and now let's click on play. So out here you can see that on pressing the play button and now we're seeing that the cube on the right side is not affected by the laws of physics and it doesn't move because the skin dramatic property has a check mark. Besides it, however, its presence makes the plan plank react differently. Right? And it's kind of now the plank is in the sideways position and because that plank is being affected by the red cube then even um in you know, consequently even the blue cube is affected. Right? So let's try this out again. There you go. So what if I have both of these said as is Kinnah Matic, then obviously nothing will happen basically the cubes won't like fall right? But this plank is a swing a bit um there you go. Now. Uh one thing to notice is or note is that two objects will reach the ground at the same time if they're dropped simultaneously from the same height, no matter their weight. And this is because both the objects are affected by the same gravitational force. Right? So that's just something to keep in mind and then there's also another cool tip and this is that you can basically change the default value of gravity. Right? So for that what you need to do is go to edit and then go to project settings and then um come to physics right and out here you can see that the default value of gravity is minus 9.81 I believe it's neither is per second in the y axis. So you could change and this is how it is in the physical world but you can change that right if you want to do that and that's pretty much it for the rigid body component. Now the rigid body component, like I said is important for collisions. Now when two objects collide is just not, it's not only the rigid body component but it's also the collider component which is important. So there's two components that are important in unity. When um in relation to collisions, one is the rigid body component that we just went over. And the second one is the collider component. Basically rigid body and colliders work together. Right? So in collision detection between two or more objects, these two will work together. One will detect and handle collisions which is the collider component, whereas the other one allows a game object to react to the laws of physics which is the rigid body component that we just talked about
143 Views 0 Likes 0 Comments

A RigidBody in Unity3D is a component that, when added to any game object, allows it to interact with fundamental physics behavior, for example, forces...

Comment
Leave a comment (supports markdown format)