I created a simple door and key system, using generic assets of a cone to represent the key, and a cube to represent the door…
This works pretty well so far, and accomplishes the following:
- If you try the door without grabbing the key, it tells you that you need to get the key.
- If you grab the key, it assigns the variable saying you now have it, and then destroys the cone that acts as the key. (Representing the key pickup.)
- Once you have the key, if you try the door, it destroys the cube that acts as the door. (Representing the door opening.)
Now, my challenge is this: Is there a simple way to have multiple keys on a level that corresponds with specific doors? (i.e. I have key 1, 2 and 3, which open door 1, 2 and 3, respectively.) I have been trying to work through the logic that says the following:
- If you try any of the three doors and have no keys, it will tell you “you don’t have a key”. (Sure, I could cheat and say “you don’t have the key for THIS DOOR”, but that would be a cop-out.)
- If you have one key, and you try the wrong door, it will tell you “this is not the correct key for this door”
- If you have more than one key, and you try the right door, it will tell you “none of the keys you have open this door”
- If you have the right key in your inventory for the door, it will open (or destroy, in this case) the door
Shy of building (what my brain can only comprehend are) giant blueprints for each of the keys and doors, is there a simple way to make this work? I can think it through, having multiple branches and multiple outcomes, but I think there may be a better way to do this…
I was considering trying to determine if each ‘key’ could be assigned a unique value so that any combination would add up to a specific total which would tell you which keys you had, and then this calculation could be applied to each door itself.
For example:
- Key 1 is worth 1
- Key 2 is worth 3
- Key 3 is worth 5
So… if you owned the following combinations:
Key 1 alone, the total would be 1.
Key 2 alone, the total would be 3.
Key 3 alone, the total would be 5.
Key 1 and 2, the total would be 4.
Key 1 and 3, the total would be 6.
Key 2 and 3, the total would be 8.
Key 1, 2 and 3, the total would be 9.
Am I thinking too much here? Obviously, having only three keys wouldn’t be as confusing as having ten keys and ten doors, but would something like this work? Is there something much better than this, that could accommodate what I’m looking for?
Thanks, in advance!