Skip to content

Instantly share code, notes, and snippets.

@jmbeach
Created January 3, 2015 20:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jmbeach/501eb3a8326c6e6fd999 to your computer and use it in GitHub Desktop.
Save jmbeach/501eb3a8326c6e6fd999 to your computer and use it in GitHub Desktop.
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