O'Reilly logo
  • Micheal Peters thinks this is interesting:

using UnityEngine;
using System.Collections;

public class GoalScript : MonoBehaviour {

    void OnTriggerEnter (Collider collider) {
        GameObjectcollidedWith = collider.gameObject;

        if (collidedWith.tag == gameObject.tag) {
        GetComponent<Light>().intensity = 0;
            Destroy (collidedWith);
        }
    }
}

From

Cover of Sams Teach Yourself Unity® Game Development in 24 Hours, Second Edition

Note

Small error in this script: Line 7, GameObjectcollidedWith = collider.gameObject;
should be GameObject collidedWith = collider.gameObject;

The missing space will cause an error.