Key to use to unlock a teleporter


For my game I have several teleporters I want to have one of the teleporters locked until you collect a key which will enable the teleporter to be usable.

I have no idea where to start. At the moment the teleporters work. But what script would I need to add to the key and what would be needed to add to the teleporter?

Add a blocking bit of geometry in front of your teleporters, then when a key is collected disable the blocker.

In script, the destroy block would be something like this:

level_block = GameObject.Find("PortalBlock");

Just add that after an If statement for determining key collection.

Key collection:

function OnControllerColliderHit(hit:ControllerColliderHit)
    if(hit.gameObject.tag == "key")
        Debug.Log("You picked up the key!");
        key++;  // You should probably use a boolean here if you just have one key, but I've got this set to require a certain number of items to unlock.