Created
July 16, 2016 16:12
-
-
Save timsgardner/b49dbf6010f618c8ee65019325f9669c to your computer and use it in GitHub Desktop.
raycast helper
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| public class RayCastHelper { | |
| public static RaycastHit[] raycast(Ray ray) { | |
| RaycastHit[] hits = new RaycastHit[0]; | |
| RaycastHit hit; | |
| if (Physics.Raycast(ray, out hit)) { | |
| hits = new RaycastHit[1]; | |
| hits[0] = hit; | |
| } | |
| return hits; | |
| } | |
| public static float[] raycastPlane(Plane plane, Ray ray){ | |
| float[] outgoing; | |
| float dist = 0; | |
| if (plane.Raycast(ray, out dist)){ | |
| outgoing = new float[1]; | |
| outgoing[0] = dist; | |
| } else{ | |
| outgoing = new float[0]; | |
| } | |
| return outgoing; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment