Created
January 3, 2015 20:58
-
-
Save jmbeach/501eb3a8326c6e6fd999 to your computer and use it in GitHub Desktop.
This file contains 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; | |
using System; | |
public class PathPoint : MonoBehaviour { | |
int radius = 10; | |
public Func<Collider,GameObject, int> TriggerEnterAction; | |
public Func<Collider, int> TriggerExitAction; | |
public GameObject ObjectToDetect; | |
void OnDrawGizmos(){ | |
Gizmos.color=Color.blue; | |
Gizmos.DrawWireSphere(transform.position,radius); | |
} | |
void Start() | |
{ | |
var collider = gameObject.AddComponent<SphereCollider>(); | |
collider.isTrigger = true; | |
collider.radius = radius; | |
} | |
void OnTriggerEnter(Collider other) | |
{ | |
if (other == ObjectToDetect.collider) | |
{ | |
TriggerEnterAction(other,gameObject); | |
} | |
} | |
void OnTriggerExit(Collider other) | |
{ | |
TriggerExitAction(other); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment