Game Development Reference
In-Depth Information
Step 3. Press play. The sphere will fall downward.
Step 4. Press stop and change the gravity via the main menu's Edit >
Project Settings > Physics; in the Inspector click on Gravity to expand.
You may want to set it to a positive y value or even have it go to the
side with a change to the x . You choose.
Step 5 . Press play to see the effect of the new gravity settings.
2.5.2 The First Law of Motion
Every body continues in its state of rest, or of uniform motion in a straight
line, unless it is compelled to change that state by forces impressed upon it.
This means that an object will remain stationary and a moving object will
keep moving in the same direction unless push or pulled. In the real world, a
number of different forces act to move or slow objects. These include gravity
and friction. In addition, objects colliding with each other will also act to
change their movement.
Unity Hands On
Newton's First
Step 1. Create a new Unity Project. Ensure that the y axis is pointing
up and position the Main Camera to the same view.
Step 2. Select GameObject > Create Other > Plane from the main
menu. Resize the plane to twice its original size to create a large
ground area. You can do this by pressing “R” while the plane is
selected or changing the scale x , y , and z values in the Inspector
to 2. Add a directional light. Add a grass or dirt seamless texture to
the plane.
Step 3. Select GameObject > Create Other > Cube from the main
menu. Zoom in to center the cube in the Scene. Lift the cube so that it
is slightly above the ground.
Step 4. With the cube selected in the Hierarchy, select Component >
Physics > Rigidbody from the main menu to add physics processing to
the cube.
Step 5. Press play. The cube will fall until it hits the ground and stops.
Although the plane doesn't have a Rigidbody attached, it does have a
Collider. Select plane in the Hierarchy and look for the Box Collider in
the Inspector. This collider is used by the physics system. Although the
ground plane is not affected by the cube hitting it, the cube, because
it has a Rigidbody, is stopped by the collider of the plane.
Step 6. Lift the cube higher above the plane. Add a Rigidbody to the
plane.
Step 7. Press play. Note that the plane and the cube both fall at the
same rate.
Search Nedrilad ::




Custom Search