Advertisement
dnnkeeper

Unity Layered cast test

Sep 4th, 2013
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class RaycastTest : MonoBehaviour {
  5.  
  6.         public int LayerIndex = 8;
  7.  
  8.         void Update()
  9.         {
  10.                 if (Input.GetMouseButton(0) )
  11.                 {
  12.                         Ray R = Camera.main.ScreenPointToRay (Input.mousePosition);
  13.                         foreach (RaycastHit hitinfo in Physics.RaycastAll(R,10000.0f, LayerIndex ) )
  14.                         {
  15.                                 Debug.Log("HIT "+hitinfo.collider.gameObject+" AT LAYER "+LayerIndex);
  16.                         }
  17.        
  18.                 }      
  19.                 if (Input.GetMouseButton(1) )
  20.                 {
  21.                         Ray R = Camera.main.ScreenPointToRay (Input.mousePosition);
  22.                         foreach (RaycastHit hitinfo in Physics.RaycastAll(R,10000.0f ) )
  23.                         {
  24.                                 Debug.Log("HIT "+hitinfo.collider.gameObject+" WITH LAYER"+hitinfo.collider.gameObject.layer);
  25.                         }
  26.                
  27.                 }
  28.         }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement