Skip to content

Instantly share code, notes, and snippets.

@moon-goon
Created January 23, 2016 00:43
Show Gist options
  • Save moon-goon/3bbdb01d5788479dbe1d to your computer and use it in GitHub Desktop.
Save moon-goon/3bbdb01d5788479dbe1d to your computer and use it in GitHub Desktop.
void OnCollisionEnter(Collision target) {
// create a gameobject (a cube for this demo) name it "enemy"
// and your argument(target) is setup so that object can be collided with
if (target.gameObject.name == "enemy") {
// Change the player's color to green when collide occurs
gameObject.GetComponent<Renderer>().material.color = Color.green;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment