基于层的碰撞检测 Layer-Based Collision Detection

原文链接: http://game.ceeger.com/Components/LayerBasedCollision.html

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.
设置游戏对象来进行基于层的碰撞检测

  1. Select a layer your Game Objects will belong to
    选择选定游戏对象的层

  2. Repeat 1 for each Game Object until you have finished assigning your Game Objects to the layers. 
    重复第1步,直到你完成对该层的关联操作
  3. Open the Physics Preference Panel by clicking on Edit->Project Settings->Physics. 
    项目设置->物理,打开物理引用界面
  4. Select which layers on the Collision Matrix will interact with the other layers by checking them.
    在碰撞矩阵中选择要与其他层相互作用的层,勾选即可

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值