Two arrays branch returning true and false at the same time

Hello, that’s my first post here and i dont know if i am in the right area but
i have this branch to unlock the door only if player have the right key;base64

but this branch is returning true and false at the same time


how can i fix this?

well the for each loop will check EVERY key type sequentially, so it will compare ALL the key types so it will return FALSE for the ones that dont match and return TRUE once it finds the right one.

You may want to find a way to set one key as an “active key/KeyHeld” object and then compare that one key type to the door type, so it will only return True OR False.

Here is something that could help

create an enum of the types of doors. put that enum in each Key Actor. Set a key as active before trying to open the door. and then in the check just set the door type.

I would recommend however you do the check on the DOORs actor, not the characters BP.

thank you very much, that worked! :smiley:

Awesome!!! I am glad I could help!

From the video I watched there could be an issue if you pick up the Correct key first and then pickup the wrong one, if you dont leave the correct key available to set as active after pickup then u may be left with the wrong key active, maybe have an inventory of keys on screen and click on the one you want to make active? id love to see what you have so far in action =)

Another approach could be to make an array of keys and add as you pick up and before doing the check for the right key you could cycle through the keys array and if you have it set that key in the as “active key” and then do the check if it can open the door :wink:

I am just winging it of the top of my head right now, but seems plausible