首页 > 编程语言 > 详细

Unity-layermask的问题

时间:2015-04-28 13:30:59      阅读:187      评论:0      收藏:0      [点我收藏+]
 1 using UnityEngine;
 2 using System.Collections;
 3 
 4 public class NewBehaviourScript : MonoBehaviour {
 5     private RaycastHit info;
 6     LayerMask M1 = 1<<8;
 7     LayerMask M2 = 9<<10;
 8     // Use this for initialization
 9     void Start () {
10         if (Physics.Raycast(this.transform.position, new Vector3(0, 0, 1), out info,M1))
11         {
12             
13             print(info.collider.gameObject.name); }
14     }
15     
16     // Update is called once per frame
17     void Update () {
18         Debug.DrawLine(transform.position, info.point, Color.red);
19     }

之前就是这样写,但是发现不是m1的碰撞体还是被检测到了,今天 终于发现问题了

不知道是不是bug,就是 如果你不加distance的话 后面的mask unity是无视的

改成这样

(Physics.Raycast(this.transform.position, new Vector3(0, 0, 1), out info, Mathf.Infinity, M1))

就正常了。

Unity-layermask的问题

原文:http://www.cnblogs.com/mukeyang/p/4462563.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!