In Unity 3.x we introduce Layer-Based collision detection, which is a way to make Game Objects collide with another specific Game Objects that are tied up to specific layers.
在Unity3.x中我们引入了基于层的碰撞检测,即在GameObject和绑定在指定层中的特定的GameObject之间进行碰撞检测。
Objects Colliding with their own layer.
In the image above you can see 6 GameObjects, (3 planes, 3 cubes) and the "Collision Matrix" to the right that states which Objects can collide with which layer. In the example, we have set the Collision Matrix in a way that only GameObjects that belong to same layers can collide.
在上图中,你能看到6个游戏对象(3个平面,3个立方体),以及右边的"碰撞矩阵"。该矩阵描述了哪一个对象能和哪一层产生碰撞作用。例如图中的碰撞矩阵设置,使得只有属同层的游戏对象能相互碰撞。
Setting GameObjects to detect Collisions Based on Layers.
设置游戏对象来进行基于层的碰撞检测
- Select a layer your Game Objects will belong to
选择选定游戏对象的层 - Repeat 1 for each Game Object until you have finished assigning your Game Objects to the layers.
重复第1步,直到你完成对该层的关联操作 - Open the Physics Preference Panel by clicking on Edit->Project Settings->Physics.
项目设置->物理,打开物理引用界面 - Select which layers on the Collision Matrix will interact with the other layers by checking them.
在碰撞矩阵中选择要与其他层相互作用的层,勾选即可