Are you wanting the door to unlock when the player picks up the key, or when the player touches or uses the door with the key in the inventory? If you’re wanting it to happen when the player touches the door, you can do it similarly to how you handled collision with the key. Just have the door check if the player has the key when the player collides with the door.
You can access scripts attached to other objects using GetComponent<>().
http://unity3d.com/learn/tutorials/modules/beginner/scripting/getcomponent
DoorUsed doesn’t seem like a clear idea for a class. I’m not really sure what it’s supposed to represent. It’s called “DoorUsed” but it’s handling animation…? Classes should usually have nouns as their names because they should represent objects (or at least hypothetical objects).
If the key and the door are both in your scene (rather than instantiated at runtime), you can easily access the scripts from each other.
For example, you could have your Door class (make a Door class that represents the door itself) and your SilverKey class.
Give a member variable to the SilverKey class like this:
public Door doorToOpen;
where Door is the name of your Door class, and doorToOpen would be a variable that holds a reference to the Door object.
Now click on one of your keys in your scene hierarchy, and in the inspector you should see under the SilverKey script component, there is a Door To Open field. You can just drag the Door component from your door object that you want to open into this slot. You can also click the little selector thing and a list of objects in the scene will appear, and you can choose the object with the attached script you want to reference there.
Then you’ll have access to that specific script with your doorToOpen variable.
So if, for example, your Door class had a method like “Unlock()” that opened the door, you could easily access it from within your SilverKey class/script like this:
doorToOpen.Unlock();
If you need to instantiate the keys at runtime (rather than having them in the scene from the start), there are a variety of ways you could initialize the doorToOpen variable. For example, you could have an method in your SilverKey class like this:
IdentifyDoor(Door d)
{
doorToOpen = d;
}
then you could just call it from a variety of places. If for some reason, you want the door itself to instantiate the key, you could have the Door instantiate the key and then just call the IdentifyDoor method immediately afterward, passing “this” as the parameter. Or, you could have some kind of key generator object in your scene that instantiates keys and then calls the method that has the door it ‘injects’ into the keys set in the inspector like described before.
You can also tag your door with a ‘Door’ tag and then have the SilverKey class find it with FindObjectWithTag(“Door”).GetComponent(). Note that in this example, the first “Door” is the string identifying the tag, and the second Door is the name of the class/script component on the object that will be found.