Blueprint communication with counters
I think I've read all the documentation and posts regarding my question, but the more I read the less I understand. I need to do (what seems to be) an extremely simple thing, but the more I try the more my mind is blown. Long story short – There are 4 similar buttons and a door. When the player steps on each button (the order doesn't matter) the door opens. Now, what I've been trying to do:
I want to create a public variable "ButtonCounter", and when the player steps on that physical button, it adds +1 to the variable. And when the variable is equal to 4, the door opens. So first, where do I store that "Button Counter" variable? As I get it, since all 4 buttons are instances of the same button_BP, they don't share actions made to the variable between them, right? So when I step on all 4 buttons, I won't have one "ButtonCounter" that is equal to 4, instead I will have 4 separate "ButtonCounter" variables and each one of them will be equal to 1, right? So do I need to store the "ButtonCounter" variable in the door_BP? And how do I actually make the communication between door_BP and button_BP? As I got it after reading the documentation and posts, I need to use "Cast to", but after all my attempts I failed. I'm not sure why but I just can't understand how I'm supposed to use it in thins situation. Like, from where to where should I cast in this situation? And what and where that "Object" box in "Cast to" should be? And what's the difference between "cast to bp_door" and "cast to bp_door class". I'm sorry if the whole thing seems stupid. I wouldn't waste your time if I could figure it out on my own. But I just can't.
Yes, you should put ButtonCounter variable in door_BP, but you don't need to cast to anything.
Inside button_BP create a variable and call it something like ref_door_BP and set the variable type to 'door_BP reference'. Just click on the variable type dropdown menu and search for door_BP and you should find it.
Next you need to activate Instance Editable in the ref_door_BP variable setup.
In door_BP, drag the ref_door_BP variable into the blueprint graph and choose get. Drag a wire from it and search for ButtonCounter. If this does not work try to compile your blueprint and try again. If it still does not work something has been setup incorrectly or I am not very good at explaining this. :)
If it works you can place a button and a door inside you level.
If you select the button you can find the variable under Default in the Details tab. Next to the variable is a dropdown menu where you should be able to select the door_BP.
And if this worked you can add more buttons and do the same.
I didn't have time right not to create screenshots but I can do that a little later if you need those.
answered Aug 07 '17 at 02:40 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here