Created
November 11, 2013 21:49
-
-
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.
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; | |
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