ive made a boolean called dooropen and for example sakes set it to true so that when i press the interact key (E) on a door, an open animation plays and a sound effect plays, whereas when dooropen is false, the door plays a locked sound efefct and doesnt open. the animation isnt the problem as i tested it out when removing the branch entirely and just connecting the event to the gate. what i want is for the gate to open when the boolean is true and to remain closed when it is false. id love any help. thank you all.
sorry for the late reply, was away for the holidays. yes it fires a string which says âhelloâ once i press E. with door open? being true, the door does open. but i want that to be set as true once you collect an item in game, so how would i go about setting the boolean to true in another blueprint? ive tried using global variables and stuff before and its never really worked. i basically just want the door to open once an item is collected. thanks for all your help so far.
It would be a bit of a crap system if the door unlocks the moment the player picks up the key
Maybe they need to satisfaction of unlocking the door.
So the bool âdoor openâ in the door BP should be false by default.
When the player interacts, the door can check if the player has the key. If so, you can play an unlocking sound ( or show a message ), and the door sets the bool to true.
Then with the next interaction, the player can open the door.
There are a variety of ways to do it, but the most direct is called âdirect blueprint communicationâ. This involves BP1 having a reference to BP2. Most directly for you that would mean the door could do a
( assuming your player is first person ).
Does that make sense?
at the top you can see the system i had in place originally, and the bottom is the event i set up. i made it so that when you enter the box that the item is in, haskey is set to true and hello is printed. in my testing, hello is printed but only when im inside the box, so i assume haskey goes back to false aswell once i leave the box. if i could make it so that haskey is set to true forever once i enter the box, it wouldnt be perfect by a long shot but it would be major progress. is this the sort of thing you were talking about?
Youâll notice youâre not setting âhaskeyâ to false anywhere. So, once itâs set, it will always be true
I think this is what you have now.
hmm thats what i thought aswell but it still is just not opening the door. is it ok if i just give a more in depth description of my game and maybe we can work out something more taoilred because ive been stuck on this one bit of code for like a month now and i kinda need it to work to move on. youve been amazing so far and thank you for your helpâŚ
so essentially, my game is a remake of âbaldis basicsâ where a character needs to collect a certaina mount of notebooks before âbaldiâ catches them.
what i want to do here is, as the game is peaceful until you get your second notebook, have the doors to the next part of the game be locked, until that second notebook is collected. ill even settle for it just being the first notebook at this point if itâs easier.
and then once the boolean dooropen? or whatever itâs even called now, is set to true, a bunch of things happen off of it e.g. characters spawning, doors opening, music kicking in e.t.c.
and that is essentially the game being in full swing, but it all relies on this single boolean. i hope ive helped clarify some stuff, and thank you for all your help so far.
So the second notebook can set the âhas keyâ bool in the player ( most logical place ), and kick off all this other stuff.
Then, in the door, you can just say
thanks for the help. ive done what you said in the door (bottom image) but it still isnt opening. just as a test i had haskey? set to true on beginplay (top image) and print hello, and hello appears, but the door STILL isnt opening. any ideas why? i think its a problem with the boolean not setting properly or something. when i set haskey? to be true by default, the door opens, so for some reason haskey? isnt setting to true, or if it is it isnt staying that way. thanks for all your help so far
Haskey is a variable in the player, and needs to be true. Do you have that?
i set it to be true in the firstperson blueprint in the top example if thats what youre asking. normally i would set it to be true in the notebook bluepritn and just cast to the first person blueprint, but for test purposes i just set it in first person. but its still treated as false for some reason
update: just tried it again and IT WORKS⌠kinda. it works when ive ended the overlap with the box that the collectible is in, when i want it to be set to true once ive picked up the SECOND notebook. any ideas as to how i could code that. the setting issues are all fixed so thats my only real issue now. thank you SO MUCH you have no idea how long ive been stuck on this
Make it so that when the player picks up the second notebook, they âhaskeyâ variable is set to true
amazing, thank you for all your help