Branch error on the door unlock/lock function

Hi, I’m making a simple thing in my game, where if the player tries to open the door it will play a locked sound and it won’t open, but If the player finds the key the door opens and the sound no longer plays. I got the functionality down, but for some reason It still plays the locked sound, If I try to press the same button midway the event or after it.
To sum up, the door doesn’t open If the player doesn’t have the key and it does open if the player has it, but If I spam the keybind button for opening the door during the point where I’m opening the door or after It’s been open, then the repeats itself, even though it’s shouldn’t because the player has the key, therefor the bool variable.

Here’s my blueprint for the key:

My errors:

And where the issue actually happens → Door blueprint. The error is from the first has key? branch but I don’t know how to fix it:

And just for reference, I also added some texts on the actors when the player overlaps it’s collision box, saying interact, locked etc. to make things easier for the player, therefor all these hidden in game on and off switches.

Looking at your picture, that branch uses a variable from a function that doesn’t run (cast to Third Person character) because it is part of a different event.

You should pass the interactor via the interact event, or if the player is the only person who can interact, you can just get the player character, cast it, and get that bool.

I’m sorry man, but I don’t really know what you mean, could you please specify what I should change here.

GetPlayerCharacter > CastToBP_ThirdPerson > hasKey. The CastToBP_ThirdPerson must be triggered from your Interact Event. The OtherActor and CastToBP_ThirdPerson that you are trying to use in your Interact Event are part of a different event so you can’t use them in the Interact event.

1 Like

Thanks man I appreciate the help, I can’t believe it was actually something so simple and I didn’t even understand it at first, either way thank you and have a nice day.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.