I know how to make the raycast ignore a layer but I want it to ignore layers 9 and 10 but collide with the rest of the layers.

I would do it the other way round: declare the variable private and use the SerializeField attribute. This way you can edit the variable in the inspector and keep it private so other scripts can't directly access it.

Of course when you don't want to show it in the inspector (to be able to change the layermask) you have to choose the layers in your code manually.

I take the example from the OP:

  1. var layerMask =(1<<9);
  2. layerMask |=(1<<13);
  3. layerMask |=(1<<15);
  4. layerMask =~layerMask;

Or in one line:

  1. var layerMask =~((1<<9)|(1<<13)|(1<<15));

This would exclude layer 9, 13 and 15.

Keep in mind that the IgnoreRaycastLayer should also be ignored. You can use the Physics.kIgnoreRaycastLayerconstant which is the layermask for the layer2 (has a value of 4 == 1 << 2 ). So just add this:

    1. [...]
    2. layerMask |=Physics.kIgnoreRaycastLayer;
    3. layerMask =~layerMask;
    4. [...]

Making raycast ignore multiple layers的更多相关文章

  1. 阅读记录:Learning multiple layers of representation(杂乱笔记)

    典型的浅层学习结构: 传统隐马尔可夫模型(HMM).条件随机场 (CRFs).最大熵模型(Maxent).支持向量机(SVM).核回归及仅含单隐层的多层感知器(MLP)等. 局部表示,分布式表示和稀疏 ...

  2. BPTT for multiple layers

    单层rnn的bptt: 每一个时间点的误差进行反向传播,然后将delta求和,更新本层weight. 多层时: 1.时间1:T 分层计算activation. 2.时间T:1 利用本时间点的误差,分层 ...

  3. MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.2 Static Map with Two Layers

    MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.2 Static Map with Two Layers 一.前言 上一篇博客< ...

  4. Getting svn to ignore files and directories

    August 27, 2013Software Developmentresources, subversion, svn, tutorial, version control Who knew it ...

  5. HANA SQLScript

    数据类型 日期时间类型 DATE(日期) DATE 数据类型由年.月.日信息组成,表示一个日期值. DATA 类型的默认格式为‘YYYY-MM-DD’. YYYY 表示年, MM 表示月而 DD 表示 ...

  6. apex-utility-ai-unity-survival-shooter

    The AI has the following actions available: Action Function Shoot Fires the Kalashnikov Reload Reloa ...

  7. Edge Intelligence: On-Demand Deep Learning Model Co-Inference with Device-Edge Synergy

    边缘智能:按需深度学习模型和设备边缘协同的共同推理 本文为SIGCOMM 2018 Workshop (Mobile Edge Communications, MECOMM)论文. 笔者翻译了该论文. ...

  8. MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.5 Adding a raster layer

    MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.5 Adding a  raster layer 一.前言 MapServer不仅支持 ...

  9. [Tensorflow] Cookbook - The Tensorflow Way

    本章介绍tf基础知识,主要包括cookbook的第一.二章节. 方针:先会用,后定制 Ref: TensorFlow 如何入门? Ref: 如何高效的学习 TensorFlow 代码? 顺便推荐该领域 ...

随机推荐

  1. [Effective JavaScript 笔记]第30条:理解prototype、getPrototypeOf和__ptoto__之间的不同

    原型包括三个独立但相关的访问器.这三个单词都是对单词prototype做了一些变化. C.prototype用于建立由new C()创建的对象的原型 Object.getPrototypeOf(obj ...

  2. IOS开发的目录结构

    http://www.itjhwd.com/iosmolukaifa/ 目录结构      个人总结:  =============================================== ...

  3. linux下vim命令详解 转自: zhanglong0426

      高级一些的编辑器,都会包含宏功能,vim当然不能缺少了,在vim中使用宏是非常方便的: :qx     开始记录宏,并将结果存入寄存器xq     退出记录模式@x     播放记录在x寄存器中的 ...

  4. nginx(四)初识nginx日志文件

    nginx 日志相关指令主要有两条,一条是log_format,用来设置日志格式,另外一条是access_log,用来指定日志文件的存放路径.格式和缓存大小,通俗的理解就是先用log_format来定 ...

  5. django-cms 代码研究(二)bugs?

    djangocms集成到现有项目中后,发现了几个问题: 1. 现有项目的url匹配失效,下面requests请求被交给djangocms处理了 url(r'^admin/', include(admi ...

  6. python遍历数组的两种方法

    第一种,最常用的,通过for in遍历数组 1 2 3 4 5 6 7 8 colours = ["red","green","blue"] ...

  7. 局域网所有机器都能连接MySQL数据库的设置命令

    Sql代码: grant all privileges on *.* to root@"%" identified by 'abc' with grant option; flus ...

  8. abstract class和interface的区别

    1. 引言 2. 概念引入 ●什么是接口? 接口是包含一组虚方法的抽象类型,其中每一种方法都有其名称.参数和返回值.接口方法不能包含任何实现,CLR允许接口可以包含事件.属性.索引 器.静态方法.静态 ...

  9. 《ASP.NET1200例》当前上下文中不存在名称configurationmanager

    当前上下文中不存在名称ConfigurationManager的解决方法 今晚做项目在DBHelper.cs类中的数据库连接要改到web.config里面调用,结果在编译的时候却发现提示错误: 当前上 ...

  10. debian下mysql主从配置

    1.确保master/slave只有一份/etc/mysql/my.cnf , 不要在其他地方再有my.cnf (如/etc/my.cnf  /usr/local之类) 2.master配置: 在[m ...