topical media & game development
lib-unity-tutorial-m2h-2-Assets-Game-1-Catch-eggs-Scripts-EggCollider.cs / cs
using UnityEngine;
using System.Collections;
public class EggCollider : MonoBehaviour {
PlayerScript myPlayerScript;
void Awake()
{
myPlayerScript = transform.parent.GetComponent<PlayerScript>();
}
void OnTriggerEnter(Collider theCollision)
{
//In this game we don't need to check *what* we hit; it must be the eggs
GameObject collisionGO = theCollision.gameObject;
Destroy(collisionGO);
myPlayerScript.theScore++;
}
}
(C) Æliens
04/09/2009
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.