Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Use the same variable in two different blueprints

Hello, i've got a problem with two blueprints that should communicate. I've got a buttonBP and a doorBP, when you press the button the door have to open. The variable wich says if it's open or not is a boolean and works perfectly in the buttonBP, so the doorBP should read this variable and open the door if it's true...but I have no idea how to call the variable within the blueprints. Thanks for the help in advance.

Product Version: UE 4.19
more ▼

asked Nov 18 '18 at 03:18 PM in Blueprint Scripting

avatar image

1 1 1

avatar image Tuerer Nov 18 '18 at 03:26 PM

Actually that's not what you need, if I get it right. What you need is to set an "Open Door" function in the Door BP and call this function when the Button is pressed.

avatar image superlollo23 Nov 18 '18 at 04:28 PM

And how can i do that? Now I've create a function in the doorBP but I don't know how to call this function in the buttonBP

avatar image Tuerer Nov 18 '18 at 04:39 PM

You're going to use buttons and doors in various levels, I assume.
In this case I'd say the best solution would be to create an event in the Button BP and call it whenever the button is pressed. Next, in your Level BP you Bind to that event on Begin Play, and then you execute the Door function.
Don't mind the purple "Button" output pin, you won't have that in your Custom Event node. In my case the event goes with the button tag — it allows using one Bind Event node for multiple buttons. alt text

button.png (81.6 kB)
(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first

personally i would go with direct blueprint communication since its relatively simple and is modular. to use this approach you will have the button call a custom event on the door to open it. to do this though will require a reference to the particular door you want to target, to get this reference we will use a public variable.

to implement this system we will begin by creating a door bp, i named mine DoorTest in this example. in the doortest bp create a custom event "OpenDoor" and script your functionality to have the door open. next create your Button bp (button in the example). in the button bp create a variable (DoorToOpen) and set its type to doorTest, this is done in the details panel as shown below. next at the bottom left click the eye icon next to the variables name so it appears as an open eye, this makes it public and allows you to set its value in the level editor window later. now we just need to create the script to use the button and call the open door event. in the example i used the E key to use the button, then i got the variable and dragged off it and searched for the openDoor event.

now to actually using the doors in your level. place a door in the level then place a button as well. when you select the button in the level, if you look at the details panel in the default section you will see the variable you created earlier. if you click the dropdown it will show you a list of all instances of the door bp in the level, you can use this to set the variable to a specific door or put another way you are setting which door to open aka setting the target.

using this method you can have as many doors as you like and as many buttons too. as long as you remember to set the variable for each button to the door that it corresponds to. this system also will enable you to have multiple buttons control the same door if you wished. also this is the most basic form, you could add in some loops and arrays if you wanted one switch to control many doors. oh one more thing to note, if you are going to use a simple button input like shown you may run into a priority issue so you may need to add in a bit more functionality to control the input but thats a pretty simple thing too and i can explain it if needed.

alt text

capture.png (224.8 kB)
more ▼

answered Nov 18 '18 at 07:03 PM

avatar image

10.1k 33 10 25

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question