Skip to content

Instantly share code, notes, and snippets.

@jakevsrobots
Created November 11, 2013 21:49
Show Gist options
  • Save jakevsrobots/7421053 to your computer and use it in GitHub Desktop.
Save jakevsrobots/7421053 to your computer and use it in GitHub Desktop.
Example script that destroys a player when they enter a trigger, and also turns the trigger's object red.
using UnityEngine;
using System.Collections;
public class SphereTrigger : MonoBehaviour {
void OnTriggerEnter(Collider other) {
renderer.material.color = Color.red;
if(other.gameObject.tag == "Player") {
Destroy(other.gameObject);
}
}
void OnTriggerExit(Collider other) {
renderer.material.color = Color.white;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment