This script handles unlocking and opening a door.
Interact():
This function is called from PlayerInteraction.
This takes from the IInteraction interface. It checks if the KeyController has the correct key corresponding to that door and if the key is in the keyChain list, it will set the local hasKey bool to true.
The if statement waits until hasKey is true. If it is, it will call removeKey(string keyName) and set the isDoorLocked bool to false, disable the box collider relating to the trigger to stop re-triggering the door. Then it plays the "DoorOpenAnim" on the door. The else part of the if statement simply debugs that the player does not have the key.
Comments
Post a Comment