Opening a certain door with something specific

How to give a box a specific value.
to open a certain door with the same value.
I made a key to open a certain door but i want to know how to do the same with a box.

KEY

DOOR

Hi AbyssSYR

Change your key bool array to an int array and store your keys.
In your DOOR blueprint, instead of looping through all the keys, simply get the array and use the “Contains” node to see if the doors key value exists in the player’s key array, if true then open the door.

Hope this helps

Alex

Hi Alex

I don’t want the door to open with key the image just example.

I’m asking How to give a box a specific value.
to open a certain door with the same value.
a red door will be opened only with a red box and a green door with a green box etc…
I don’t want the door to open for me I want the door to open for the BOX

Sorry, I misread (long week ha).

There are a couple of ways of doing this. The best way would be not to use an ID at all and have the box form a relationship directly with the door.

  1. Create a custom actor BP_DoorTrigger

  2. Add a box collision component

  3. Add a variable “DoorToOpen” give it the same type as the door in the level. On the variable check the two properties “Instance Editable” and “Expose on Spawn”.

  4. Grab the begin overlap event from the box component.

  5. Add the appropriate logic to open the door (I assume it will be either a function or event call on the door once the character steps in the trigger)

  6. Add an instance of BP_DoorTrigger to the world.

  7. With the DoorTrigger instance selected, look in the details panel and you will the variable you have just created. Click the eyedropper and then click the door in the world.

The door trigger will now have a direct relationship with a specific door (no need for other validation with id’s etc).

Hope this helps.

Alex

Obviously my answer above still didn’t really answer your question, but it is a better solution (depending what you want to do).

As for adding an ID, follow a similar process. Create a custom actor, but this time make the variable an int (check expose on spawn / instance editable). This way you can assign an ID to each instance in the world.

On the door, the same sort of variable so you can compare if the ID or the trigger matches the ID of the door. The decision then would be how will the door and the trigger validate against themselves. An obvious way would be to use “GetAllActorsOfClass” but I hate using that function for a solution for this sort of mechanic.

If both my replies didn’t help, can you please give a specific example of what you’re trying to do and what objects you have available. Honestly though, direct relationships are the best to work with.

Good luck.

Alex