- Unity3D平台AR与VR开发快速上手
- 吴雁涛
- 832字
- 2025-02-26 12:47:22
3.6 其他常用内容
3.6.1 3D模型
Unity3D只支持.fbx格式的3D模型导入,如图3-22所示。

图3-22
模型的贴图可以通过将图片资源直接拖动到模型上,从而生成贴图。
此外,Unity3D还提供了一些简单的基础模型,如立方体、球体等,如图3-23所示。

图3-23
3.6.2 刚体
当为一个3D物体添加了“Rigidbody”组件后,该3D物体就变成一个刚体,可以赋予物理特性,如图3-24所示。

图3-24
其中,可以设置刚体的质量(Mass),空气阻力(Drag),是否受重力影响(Use Gravity)等,如图3-25所示。

图3-25
如图3-26所示,图中的球体因为没有刚体特性,会保持位置不变。而方块因为有刚体特性,所以会受到虚拟的重力影响而下落。

图3-26
刚体的边缘并不是模型的边缘,而是由模型的Collider组件来决定。Collider属性默认与模型一样,但是可以编辑大小,即下图中的线框。
另外,导入的3D模型默认没有Collider组件,如图3-27所示。

图3-27
3.6.3 重力
Unity3D的虚拟空间中,默认的重力和地球的重力一样。
点击菜单“Edit”→“Project Settings”→“Physics”,如图3-28所示。

图3-28
可以在“Gravity”选项中编辑重力的大小和方向,如图3-29所示。

图3-29
3.6.4 物理特性
点击菜单“Assets”→“Create”→“Physic Material”,可以添加物理特性材质,如图3-30所示。

图3-30
其中,可以设定移动中的阻力(Dynamic Friction)、静止时的阻力(Static Friction)、弹力(Bounciness),数值都是0到1的浮点,0最小,1最大,如图3-31所示。

图3-31
将该资源拖入Collider组件后就可以让该游戏对象拥有对应的物理特性,如图3-32所示。

图3-32
Unity3D的标准资源包里提供了一些物理特性的资源,可以直接使用,图3-33所示。

图3-33
3.6.5 穿透
Collider组件中,“Is Trigger”属性有穿透选项,即当两个3D游戏对象中有一个的“Is Trigger”属性被选中的情况下,两个3D游戏对象就可以被相互穿透,如图3-34所示。

图3-34
3.6.6 粒子系统
粒子系统用来在Unity3D中模拟流动的液体、烟雾、云、火焰和魔法等效果。粒子系统模拟出来的效果比3D模型动画和其他方法模拟出来的效果更节省资源。
点击菜单“GameObject”→“Particle System”就能在场景中添加一个粒子效果,如图3-35所示。

图3-35
粒子系统有众多的选项可以选择,也可以通过图片的方式制作出各种效果,如图3-36所示。

图3-36
Unity3D的标准资源里提供了一些粒子特效,可以参考,如图3-37所示。

图3-37