예제 #1
0
    void OnControllerColliderHit(ControllerColliderHit hit)
    {
        if (hit.gameObject.tag == "Pickup")
        {
            //call the Collected(...) function of the PickupController Component (script) and
            //pass the pickup we hit as the parameter for the function
            GameVariables.keyCollected = true;
            keyImage.enabled           = true;

            //this is messing up and is causing game to end with null reference exception
            pickupController.Collected(hit.gameObject);
        }

        if (hit.gameObject.tag == "Door" && GameVariables.keyCollected == true)
        {
            Destroy(hit.gameObject);
            Application.LoadLevel("Victory");
        }
    }