1 using UnityEngine;
2 using
System.Collections;
3
4
5 public
static class StandardRaycast
6 {

7
8     ///
<summary>
9     ///
Fire a raycast from an origin in any direction and length.
10     ///
Return "" if the raycast hit nothing, or if it hit a collider then return the collider's tag name
11     ///
</summary>
12     
public static string GetTagFromRaycast(Vector3 origin, Vector3 direction, float length)
13     {
14         
string retVal = "";
15         RaycastHit hitInfo;
16         
if (Physics.Raycast (origin, direction, out hitInfo, length)) {
17             retVal = hitInfo.collider.tag;
18         }
19         
return retVal;
20     }
21
22
23 }


Gõ tìm kiếm nhanh...