官术网_书友最值得收藏!

  • HoloLens Beginner's Guide
  • Jason Odom
  • 468字
  • 2021-07-02 23:35:18

Physics simulations

In this section, you will learn what Unity has to offer in terms of a physics engine.

Also known as physics simulations, these engines have been an integral part of 3D and game engines for some time, but rarely are they as easy to get into as with Unity.

A physics engine is a basic physics simulation that allows the developer to add physical properties to GameObjects, such as weight, gravity, bounce, and other factors that allow these GameObjects to act and react in different ways:

  1. Select the Hello object in the Hierarchy panel.
  2. Click on the Add Component button in the TextMesh component in the Inspector panel.
  1. Click on the Physics category:
  1. Then, select Rigidbody:
  1. Now, repeat steps 1, 2 and 3.
  2. Select Box Collider.
  3. Now, the first word is finished; we need to repeat steps 1-6 for the World object.

The Rigidbody is a component that lets Unity apply physics to an object. You can change many of the ways the object reacts to the physical changes.

The Box Collider allows the object it is applied to register collisions with other objects. The object must also have a collider of some sort. There are six types of 3D physics colliders, including sphere, capsule, and mesh for complex objects.

Now, that we have our physics components on our objects, let's set up the scenes gravity. Here, we will lighten the gravity a bit and apply a different amount of drag to each object so that they fall differently. Let's perform the following steps to do this:

  1. Click on the Edit menu option, and select the Project settings near the bottom of the menu:
  1. Click on the Physics option. This will bring up the Physics Manager in the Inspector:

Look at the first field, Gravity Y is our vertical axis. Unity has a constant gravity of -9.81 by default. 0 would be no gravity at all, and a positive number would make objects move upward.

Select the number in the Gravity Y axis and change it from -9.81 to -6.

Now, we will make a couple of changes on a per-object level so that the physics reactions are different:

  1. Select the Hello object in the Hierarchy panel.
  2. Look for the Inspector and scroll down to the Rigidbody component.
  3. Find the Drag heading and change the number to 2.
  4. Change the number in Angular Drag to 1:

Now, we will make a similar change to the World text object:

  1. Select World in the Hierarchy panel.
  2. Again, look for the Inspector and scroll down to the Rigidbody component.
  3. Change the Drag setting to 3.
  4. Change Angular Drag to 2.
  5. Now, let's save our scene by pressing Ctrl + S.
主站蜘蛛池模板: 潮安县| 昌都县| 大港区| 杭锦后旗| 白城市| 积石山| 洞口县| 如皋市| 达日县| 营山县| 辽阳市| 玛沁县| 丰镇市| 西乌珠穆沁旗| 迁安市| 洛扎县| 绿春县| 鄱阳县| 门源| 平泉县| 东源县| 静宁县| 绿春县| 宝丰县| 莆田市| 诸暨市| 兴化市| 泗阳县| 伽师县| 额敏县| 白河县| 阿拉善左旗| 寿光市| 政和县| 长汀县| 山西省| 五大连池市| 江山市| 石景山区| 玉门市| 百色市|