【Assigning Layers 分配层】Now that you have created a new layer, you have to assign the layer to one of the game objects.当你创建了一个新的层后,必须把它和一个游戏对象关联起来。
In the tag manager we assigned the Player layer to be in layer 8.在标签管理器中,把玩家层放到层8中。
【Casting Rays Selectively 选择性地投射光线】Using layers you can cast rays and ignore colliders in specific layers. For example you might want to cast a ray only against the player layer and ignore all other colliders.通过层你可以在特定的层里投射光线、忽略碰撞器。比如说,你只想在玩家层中投射光线(即光线只跟玩家层中的碰撞体作用),进而忽略其他所有的碰撞器。The Physics.Raycast function takes a bitmask, where each bit determines if a layer will be ignored or not. If all bits in the layerMask are on, we will collide against all colliders. If the layerMask = 0, we will never find any collisions with the ray.Physics.Raycast函数里操作一个掩膜位,该掩膜位的每一位决定相应的层是否被忽略。如果layerMask中的每一位都为1,则将会与所有的碰撞器作用。相反如果layerMask=0,那么将会光线将不会与任何碰撞器作用。// bit shift the index of the layer to get a bit mask| 欢迎光临 纳金网 (http://go.narkii.com/club/) | Powered by Discuz! X2.5 |