查看: 3706|回复: 0
打印 上一主题 下一主题

[Unity 组件参考手册]组件:物理组件之网格碰撞器

[复制链接]
.    

3797

主题

11

听众

5万

积分

首席设计师

Rank: 8Rank: 8

纳金币
32328
精华
41

活跃会员 优秀版主 荣誉管理 论坛元老

跳转到指定楼层
楼主
发表于 2013-1-29 17:13:16 |只看该作者 |倒序浏览
The Mesh Collider takes a Mesh Asset and builds its Collider based on that mesh. It is far more accurate for collision detection than using primitives for complicated meshes. Mesh Colliders that are marked as Convex can collide with other Mesh Colliders.网格碰撞器利用一个网格资源并在其上构建碰撞器。对于复杂网状模型上的碰撞检测,它要比应用原型碰撞器精确的多。标记为凸起的(Convex )的网格碰撞器才能够和其他网格碰撞器发生碰撞。
A Mesh Collider used on level geometry 用于台阶状物体的网格碰撞器
[Properties 属性]-----------------------------------------------------------------------------Material 材质
    Reference to the Physic Material that determines how this Collider interacts with others.
    引用何种物理材质决定了他和其他对象如何作用。
    Is Trigger 是否触发器
    If enabled, this Collider is used for triggering events, and is ignored by the physics engine.
    如激活,此碰撞器用于触发事件,并且被物理引擎忽略。
    Mesh 网格
    Reference to the Mesh to use for collisions.
    用于碰撞所引用的网格
    Smooth Sphere Collisions 平滑性状碰撞
    When this is enabled, collision mesh normals are smoothed. You should enable this on smooth surfaces eg. rolling terrain without hard edges to make sphere rolling smoother.
    当被激活,碰撞网格法线是平滑的。用于平滑表面比如由没有棱角的平滑起伏组成的起伏地标时应该激活。
   Convex 凸起的
    If enabled, this Mesh Collider will collide with other Mesh Colliders. Convex Mesh Colliders are limited to 255 triangles.
    如激活,该网格碰撞器将会和其他网格碰撞器碰撞。凸起的网格碰撞器限制在255个三角形面内。 [Details 细节]The Mesh Collider builds its collision representation from the Mesh attached to the GameObject, and reads the properties of the attached Transform to set its position and scale correctly.网格碰撞器通过附加在游戏对象上的网格构建碰撞效果,并严格按照所附加对象的Transform属性来设定其位置和大小比例。Collision meshes use backface culling. If an object collides with a mesh that will be backface culled graphically it will also not collide with it physically.碰撞网格使用背面剔除(或译背面拣选,指正面多边形挡住了在它后面的背面多边形,Direct3D将通过拣选(即删除多余的处理过程)背面多边形来提高效率的过程。)如果一个对象和被背面剔除的网格碰撞,那也不会在物理上碰撞。There are some limitations when using the Mesh Collider. Usually, two Mesh Colliders cannot collide with each other. All Mesh Colliders can collide with any primitive Collider. If your mesh is marked as Convex, then it can collide with other Mesh Colliders.使用网格碰撞器有一些限制条件。通常,两个网格碰撞器之间不会发生碰撞。所有的网格碰撞器可以和任何原型碰撞器碰撞。如果网格标记为凸起的(Convex),那么就可以和其他网格碰撞器碰撞。Colliders work with Rigidbodies to bring physics in Unity to life. Whereas Rigidbodies allow objects to be controlled by physics, Colliders allow objects to collide with each other. Colliders must be added to objects independently of Rigidbodies. A Collider does not necessarily need a Rigidbody attached, but a Rigidbody must be attached in order for the object to move as a result of collisions.碰撞器作用于刚体使Unity中的物理作用生效。因为刚体允许对象被物理系统控制。碰撞器使对象之间产生碰撞作用。碰撞器必须独立于刚体加在对象上。碰撞器并不一定需要附加刚体,但是要使移动物体具有碰撞效果必须附加刚体。When a collision between two Colliders occurs and if at least one of them has a Rigidbody attached, three collision messages are sent out to the objects attached to them. These events can be handled in scripting, and allow you to create unique behaviors with or without making use of the built-in NVIDIA PhysX engine.当两个碰撞器间产生碰撞并且其中至少一个附加了刚体时,三个碰撞信息会发送给附加他们的对象,这些事件可以被脚本处理,而且允许用户可以选择自己写脚本或使用内置的NVIDIA PhysX引擎创建唯一的行为。
TriggersAn alternative way of using Colliders is to mark them as a Trigger, just check the IsTrigger property checkbox in the Inspector. Triggers are effectively ignored by the physics engine, and have a unique set of three trigger messages that are sent out when a collision with a Trigger occurs. Triggers are useful for triggering other events in your game, like cutscenes, automatic door opening, displaying tutorial messages, etc. Use your imagination!一个可供选择的碰撞器使用方法是标记他们为触发器,仅需要选中检视面板中的IsTrigger属性选择框。触发器不受物理引擎控制,当和一个触发器发生碰撞时会发出三个独特的触发信息。触发器用于触发你游戏中的其他事件,比如过场动画、自动门开启、显示教程信息等等,发挥你的想象力吧!Be aware that in order for two Triggers to send out trigger events when they collide, one of them must include a Rigidbody as well. For a Trigger to collide with a normal Collider, one of them must have a Rigidbody attached. For a detailed chart of different types of collisions, see the collision action matrix in the Advanced section below.当然也应该意识到为了使两个触发器碰撞时发出碰撞事件,其中一个必须包含刚体。一个触发器和一个普通碰撞器碰撞,其中之一必须附加刚体。想了解不同类型碰撞的详细情况,可以参考下边进阶部分中的碰撞行为矩阵。
Friction and bouncyness 摩擦力和弹力Friction, bouncyness and softness are defined in the Physic Material. The Standard Assets contain the most common physics materials. To use one of them click on the Physic Material drop-down and select one, eg. Ice. You can also create your own physics materials and tweak all friction values.摩擦力、弹力和柔软度由物理材质中定义。标准资源( Standard Assets)中包含了大部分常见的物理材质。要使用只需点击物理材质上的下拉箭头然后选中一个,比如冰。你也可以创建你自己的物理材质并调整摩擦力的大小。
[Hints 提示]    Mesh Colliders cannot collide with each other unless they are marked as Convex. Therefore, they are most useful for background objects like environment geometry.
    除非被标记为凸起的(Convex),否则网格碰撞器间不会发生碰撞。因此,它们最常被用于背景对象比如环境布景。
    Convex Mesh Colliders must be fewer than 255 triangles.
    凸起的网格碰撞器含有的三角形面不能多于255个。
    Primitive Colliders are less costly for objects under physics control.
    原型控制器对于对象的物理控制更加节省资源。
    When you attach a Mesh Collider to a GameObject, its Mesh property will default to the mesh being rendered. You can change that by assigning a different Mesh.
    当为游戏对象附加了网格碰撞器,其网格属性将被定义为用于渲染的网格,可以通过指派其他网格来改变。
    To add multiple Colliders for an object, create child GameObjects and attach a Collider to each one. This allows each Collider to be manipulated independently.
    要给一个对象添加多个碰撞器,应该创建子对象并给每个子对象添加一个碰撞器。这使每个碰撞器可以被单独操作。
    You can look at the gizmos in the Scene View to see how the Collider is being calculated on your object.
    可以通过场景视图(Scene View )中的线框(gizmos)来查看碰撞器在你的对象上的预期效果。
    Colliders do their best to match the scale of an object. If you have a non-uniform scale (a scale which is different in each direction), only the Mesh Collider can match completely.
    碰撞器尽量匹配对象的比例。如果有一组不规则伸缩(每一维度上的比例都不相同),只能使用网格碰撞器才能完全匹配。
    If you are moving an object through its Transform component but you want to receive Collision/Trigger messages, you must attach a Rigidbody to the object that is moving.
    如果你想接收通过Transform组件移动的对象的碰撞/触发信息,你必须给移动对象附件刚体。 [Advanced 进阶]
Collider combinations 碰撞器组合There are numerous different combinations of collisions that can happen in Unity. Each game is unique, and different combinations may work better for different types of games. If you're using physics in your game, it will be very helpful to understand the different basic Collider types, their common uses, and how they interact with other types of objects.Unity中有许多不同的碰撞组合。每个游戏都很独特,不同的组合可能更好地适用于不同类型的游戏。如果你在游戏中使用了物理效果,那理解不同的基本碰撞类型会很有帮助,包括它们的常用形式及如何和其他类型的对象作用。
Static Collider 静态碰撞器These are GameObjects that do not have a Rigidbody attached, but do have a Collider attached. These objects should remain still, or move very little. These work great for your environment geometry. They will not move if a Rigidbody collides with them.指的是没有附加刚体而附加了碰撞器的游戏对象。这类对象会保持静止或者很轻微的移动。对于环境模型十分好用,当和刚体碰撞时而不会移动。
Rigidbody Collider 刚体碰撞器These GameObjects contain both a Rigidbody and a Collider. They are completely affected by the physics engine through scripted forces and collisions. They might collide with a GameObject that only contains a Collider. These will likely be your primary type of Collider in games that use physics.指的是同时附加了刚体和碰撞器的游戏对象。通过脚本的力量和碰撞完全受物理引擎的影响。可以和只包含碰撞器的游戏对象碰撞。将会成为你游戏中使用物理效果的基本类型碰撞器。
Kinematic Rigidbody Collider 运动学刚体碰撞器This GameObject contains a Collider and a Rigidbody which is marked IsKinematic. To move this GameObject, you modify its Transform Component, rather than applying forces. They're similar to Static Colliders but will work better when you want to move the Collider around frequently. There are some other specialized scenarios for using this GameObject.指的是同时包含碰撞器和刚体,并且激活IsKinematic的一类游戏对象,要移动这类游戏对象,要修改它的Transform组件,而不是用力。它们很像静态碰撞器不过对于想要不停地到处移动的碰撞器很好用。这类游戏对象还有许多其他的独特使用情景。This object can be used for circumstances in which you would normally want a Static Collider to send a trigger event. Since a Trigger must have a Rigidbody attached, you should add a Rigidbody, then enable IsKinematic. This will prevent your Object from moving from physics influence, and allow you to receive trigger events when you want to.这类对象可以用于你通常希望用静态碰撞器发出触发事件的情形下。因为触发器必须要有刚体,你应该添加刚体然后启用IsKinematic。这会阻止你的对象因物理作用而移动并且允许接收你希望得到的触发事件。Kinematic Rigidbodies can easily be turned on and off. This is great for creating ragdolls, when you normally want a character to follow an animation, then turn into a ragdoll when a collision occurs, prompted by an explosion or anything else you choose. When this happens, simply turn all your Kinematic Rigidbodies into normal Rigidbodies through scripting.运动学刚体启用与否很容易控制。这对创建人偶十分适用,通常,当你希望一个角色依照动画活动,然后由于爆炸或者其他你选择的情况而引起的碰撞导致其变为人偶。这种情况下,很简单,只需要通过脚本将运动学刚体改为普通刚体。If you have Rigidbodies come to rest so they are not moving for some time, they will "fall asleep". That is, they will not be calculated during the physics update since they are not going anywhere. If you move a Kinematic Rigidbody out from underneath normal Rigidbodies that are at rest on top of it, the sleeping Rigidbodies will "wake up" and be correctly calculated again in the physics update. So if you have a lot of Static Colliders that you want to move around and have different object fall on them correctly, use Kinematic Rigidbody Colliders.如果有刚体有时候变得静止不动了,那么它们就是进入休眠了。意味着它们将不受物理变化影响,也就不会移动。如果你把一个运动学刚体从一个休眠的普通刚体下边移走,那休眠的刚体就会被唤醒并重新被物理变化时时影响。所以如果你有许多希望四处移动并有不同的对象要恰好砸到它们的静态碰撞器,那就用运动学刚体碰撞器吧。
Collision action matrix 碰撞行为矩阵Depending on the configurations of the two colliding Objects, a number of different actions can occur. The chart below outlines what you can expect from two colliding Objects, based on the components that are attached to them. Some of the combinations only cause one of the two Objects to be affected by the collision, so keep the standard&nbsp***le in mind - physics will not be applied to objects that do not have Rigidbodies attached.基于两个碰撞对象的配置,可以产生很多不同的效果。下表概括了基于附加不同组件的两个碰撞对象所产生的效果。其中有些组合只能导致碰撞的两个对象中的一个受到影响,.所以考虑到保持标准的规则-物理效果将不会对没有附加刚体的对象生效。Layer-Based Collision Detection 基于层的碰撞检测In Unity 3.x we introduce something called Layer-Based Collision Detection, and is that you can now selectively tell Unity GameObjects to collide with specific layers they are attached to. For more info, you can click here在Unity3以后版本,我们介绍了一种称为"基于层的碰撞检测"(Layer-Based Collision Detection)的东西,可以让你有选择地控制Unity对象和他们附加的特定层碰撞。点击此处获取更多信息。【来源:互联网】
更多精彩教程,尽在web3D纳金网http://www.narkii.com/college/
分享到: QQ好友和群QQ好友和群 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
转播转播0 分享淘帖0 收藏收藏0 支持支持0 反对反对0
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

手机版|纳金网 ( 闽ICP备2021016425号-2/3

GMT+8, 2024-11-23 13:03 , Processed in 0.221545 second(s), 32 queries .

Powered by Discuz!-创意设计 X2.5

© 2008-2019 Narkii Inc.

回顶部