Making raycast ignore multiple layers
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:
- var layerMask =(1<<9);
- layerMask |=(1<<13);
- layerMask |=(1<<15);
- layerMask =~layerMask;
Or in one line:
- 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.kIgnoreRaycastLayer
constant which is the layermask for the layer2 (has a value of 4 == 1 << 2 ). So just add this:
- [...]
- layerMask |=Physics.kIgnoreRaycastLayer;
- layerMask =~layerMask;
- [...]
Making raycast ignore multiple layers的更多相关文章
- 阅读记录:Learning multiple layers of representation(杂乱笔记)
典型的浅层学习结构: 传统隐马尔可夫模型(HMM).条件随机场 (CRFs).最大熵模型(Maxent).支持向量机(SVM).核回归及仅含单隐层的多层感知器(MLP)等. 局部表示,分布式表示和稀疏 ...
- BPTT for multiple layers
单层rnn的bptt: 每一个时间点的误差进行反向传播,然后将delta求和,更新本层weight. 多层时: 1.时间1:T 分层计算activation. 2.时间T:1 利用本时间点的误差,分层 ...
- MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.2 Static Map with Two Layers
MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.2 Static Map with Two Layers 一.前言 上一篇博客< ...
- Getting svn to ignore files and directories
August 27, 2013Software Developmentresources, subversion, svn, tutorial, version control Who knew it ...
- HANA SQLScript
数据类型 日期时间类型 DATE(日期) DATE 数据类型由年.月.日信息组成,表示一个日期值. DATA 类型的默认格式为‘YYYY-MM-DD’. YYYY 表示年, MM 表示月而 DD 表示 ...
- apex-utility-ai-unity-survival-shooter
The AI has the following actions available: Action Function Shoot Fires the Kalashnikov Reload Reloa ...
- Edge Intelligence: On-Demand Deep Learning Model Co-Inference with Device-Edge Synergy
边缘智能:按需深度学习模型和设备边缘协同的共同推理 本文为SIGCOMM 2018 Workshop (Mobile Edge Communications, MECOMM)论文. 笔者翻译了该论文. ...
- MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.5 Adding a raster layer
MapServer Tutorial——MapServer7.2.1教程学习——第一节用例实践:Example1.5 Adding a raster layer 一.前言 MapServer不仅支持 ...
- [Tensorflow] Cookbook - The Tensorflow Way
本章介绍tf基础知识,主要包括cookbook的第一.二章节. 方针:先会用,后定制 Ref: TensorFlow 如何入门? Ref: 如何高效的学习 TensorFlow 代码? 顺便推荐该领域 ...
随机推荐
- MBProgressHUD使用
//方式1.直接在View上show HUD = [[MBProgressHUD showHUDAddedTo:self.view animated:YES] retain]; HUD.delegat ...
- Linux 浅谈Linux 操作系统的安全设置
如今linux系统安全变的越来越重要了,这里我想把我平时比较常使用的一些linux下的基本的安全措施写出来和大家探讨一下,让我们的linux系统变得可靠. 1.BIOS的安全设置 这是最基本的了,也是 ...
- HDOJ 1864 最大报销额(01背包)
http://acm.hdu.edu.cn/showproblem.php?pid=1864 最大报销额 Time Limit: 1000/1000 MS (Java/Others) Memor ...
- 关于ubuntu配置静态IP 无法正常上网的解决方案
在ubuntu中配置静态IP后无法正常上网. 解决: 1.在终端执行 vim /etc/network/interfaces 在文件中加入如下内容,网关要写上,我开始一直无法上网就是因为没有配置网关 ...
- 【OpenStack】OpenStack系列8之Nova详解 Neutron详解
Neutron下载安装 下载:git clone -b stable/icehouse https://github.com/openstack/neutron.git pip install -r ...
- 3Sum Closest & 3Sum Smaller
Given an array S of n integers, find three integers in S such that the sum is closest to a given num ...
- spring3 + mybatis + maven:junit测试错误
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component c ...
- iOS 使用UIWebView把oc代码和javascript相关联
首先请参看一篇文章,作者写的很明白,请参看原地址 http://blog.163.com/m_note/blog/static/208197045201293015844274/. 其实,oc和js的 ...
- c# 获取屏幕DPI
方法一:用ManagementClass来获取.需要引入System.Management.dll; using (ManagementClass mc = new ManagementClass(& ...
- Java for LeetCode 059 Spiral Matrix II
Given an integer n, generate a square matrix filled with elements from 1 to n2 in spiral order. For ...