Hi. It’s my very first question on the Hub, so I’m also saying hello. I know this question’s been asked and answered multiple times, but no thread can help me (maybe I can’t put my finger on what I’m doing wrong). Here’s my problem:
I want to have one class (locked door), and another, separate class (a button that unlocks said door) so I could move the button around and keep it connected to the door. I’ve set a variable (boolean) in the button BP class, made it public. And here’s where my problem begins: I don’t know how to get the bool into the door BP. I’m attaching a screenshot showing my BPs (I know that one of them isn’t compiled, but I did it, which didn’t help anyway).
Inside the button blueprint make a variable of the same type as the door. Then expose it by clicking the eye next to the variable. In the editor you can see the variable in the details panel and there you can select the door.
When the button is clicked you can use the variable you made to open the door or close it.
You dont need a variable inside the button unless it is a toggle button that stays pressed after you leave it.
I think I’m stupid. From what you said, all I can do is click the eye. I’m already confused after your first sentence. Can you be more specific, or add some exemplary screenshots?
You have a door blueprint right? That blueprint you call something like “BP_Door”. Inside the button you make a variable of type “BP_Door” reference. Then you click the eye.
Then place the button in the level and select it. On the right you have the details of that button. If you clicked the eye you should have a dropdown menu with the same name as your variable name.
If you have put the door in the world you can select it from the dropdown menu.
Then you just have to use that variable inside the button to call a function called OpenDoor or CLoseDoor. These functions are made inside the BP_Door.
In whichever item you are activating, you want to do a “get all actors of class”. Set the “actor class” input node, to the type that contains the boolean you are looking for, then do a foreach loop on the resulting array to find the actor you are looking for. Depending on how many of these doors you are expecting to have in the area, it might be as simple as using the first result you get back.
If you expect to have more than one on the map at a time, you will need some way to distinguish between them (tag system possibly).
You can then get/set the boolean from that reference (you may need to cast it to back to type of actor that contains the bool first).
Get All Actors → ForEachLoop of Results → Get Bool/DoWork