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. Linux下使用fdisk扩展分区容量

    导读 我们管理的服务器可能会随着业务量的不断增长造成磁盘空间不足的情况,比如:共享文件服务器硬盘空间不足,在这个时候我们就需要增加磁盘空间,来满足线上的业务:又或者我们在使用linux的过程中, 有时 ...

  2. python 异步线程简单实现

    import threading def foo(): with open(r'./result.log','wb') as f: f.write('=some logs here ==') t = ...

  3. linux shell expr 使用

    linux shell expr 使用 收藏人:春秋百味 -- | 阅: 转: | | 分享 非原创, 摘自:<LINUX与UNIX Shell编程指南> 17.5 expr用法 expr ...

  4. 【Hadoop】Hive HSQ 使用 && 自定义HQL函数

    4 HQL 4.1 官网 4.1.1 https://cwiki.apache.org/confluence/display/Hive/LanguageManual 4.1.2 性能调优 4.1.2. ...

  5. Android Studio项目引入外部库注意事项(PullToRefresh)

    Android Studio开发App项目时引入第三方库是个比较麻烦的事情.之前导入Volley就折腾了好久,导入下拉刷新控件PullToRefresh时又碰到了各种问题.在此记录一下,以便查阅. 一 ...

  6. TinyMCE textarea 输入框外部程序动态修改方法

    TinyMCE textarea 输入框外部程序动态修改方法 Public Function C2IE_TINYMCE(ByVal id As String, ByVal value As Strin ...

  7. Java for LeetCode 164 Maximum Gap

    Given an unsorted array, find the maximum difference between the successive elements in its sorted f ...

  8. Java for LeetCode 064 Minimum Path Sum

    Given a m x n grid filled with non-negative numbers, find a path from top left to bottom right which ...

  9. 1.前端笔记之html

    title: 1.前端笔记之HTML date: 2016-04-04 23:21:52 tags: Python categories: Python --- 作者:刘耀 **出处:http://w ...

  10. java单例,懒汉&饿汉

     * 单例模式Singleton  * 应用场合:有些对象只需要一个就足够了,如皇帝  * 作用: 保证整个应用程序中某个实例有且只有一个  * 区别: 饿汉模式的特点是加载类时比较慢,但运行是比较快 ...