Simple explanation on how to share variables

I’ve read and watched every video I can find on the subject but none of them actually work when trying in my level. How do I get a variable created in one blueprint to be called (get) in another.

I.e my level has a group of buttons, when clicked in sets a bool to true. Which I would like to get into another blueprint which receives the bool variables of each button and then outputs the desired results.

I can create variables and I’ve followed the videos/guides, but I don’t understand what the functions are for. I can’t call them in any other blueprints. Even the unreal tutorials aren’t helpful as I can’t replicate what they do. My functions simply do not show up.

Can someone please give me the simplest answer (with pictures if helpful), I’m starting to give up on unreal engine 4

Uh, it seems like you need to slow down a bit. Programming, even with the simple Blueprints, is not
that easy to understand if you try to rush it.

Your BPs are something like Classes. A Class has it’s functions and variables that are used inside the Class.
This is not different in C++. If you want to use a Variable or a function in another Class, you need to get a
reference to the class. This can be done by using the Begin Overlap function of a collider for example.
Or by using “Get All Actors of Class” node. Although this would give you ALL actors and not a single specific one.

I recommend you to watch the first Tutorials again. In the Tutorial Series for the Level Creation, i think he build a door
and used it’s function to open it.

He also works with Colliders here. To learn programming you need time and you need to get some basic things and try to understand them. Follow the tutorial and try to use this for your problem. If you can’t get it to work, step back and take something easier. A programmer is not made over night. It takes some time.

PS: If you don’t even understand what functions and variables are and how to use them, i think you should watch some basic programming tutorials. Learning a bit basic c++ helps you very fast to understand what you are doing with the BP. You can watch the C++ Tutorial of Epic ( with a lovely woman explaining you some coding (: )

You don’t have your class.

If you want to use a function which is not within the same blueprint you have to get it somehow (with the event begin overlap or event hit).

Cast it to your class and use the result to trigger your functions.

Or read up on blueprint interfaces as they do pretty much exactly what you want.

Hi thankyou for the quick response, I think the problem I’m having is not really the programming aspect, but what, when and why you do certain things in one blueprint and not the other.

The frustrating thing is I made everything work fine with “Onactorbeginoverlap” but now I’m trying to pick up a trace hit on the button (which is just a box/static mesh) and now I can’t call a function a simply because you have to create a function in the button actor to then fire off another blueprint (this case the level blueprint).

I will have to just keep drumming away at it until it makes sense. I’ve done programming in the past, a fair bit in both udk and source but the blueprint gloss over things with a sparkly paint which makes you think there simple to work with

Simplest solution if object A and object B are in the same level , then the simplest solution is to drag and drop both objects into level blueprint and Get value from b and pass it to an event of a function in object A.

Wait what?

You have your character that uses the Line Trace Node. If you hit the button, you want to fire a function of that button?

Normaly you would break the Hit Result of the Line Trace and cast the “Hit Actor” to the Button Class. After that, you can call the function from the return value of the cast node. I don’t understand your problem :confused: This is nearly the same as the c++ version of it.

Or what is your problem? Could you maybe ilustrate it a bit more?

Because i don’t understand what your Level Blueprint has to do with your Button that you found with the Trace :open_mouth:

You have different buttons, that just change the place the Gate will port you?

So you have a function inside your GateBlueprint that ports you to a place when entering a collider.

This place should be represented as a variable. Your buttons would have a function called “ChangeDestination”. They should be all the same BP. Only a predefined variable, with the Destination that Buttons is bound to, should be the difference. Now you would Line Trace from your CharacterController on pressing left mouse button. The HitResult would get breaked and you would take the HitActor and Cast it to the ButtonBP. The Return Value of the Cast Note can call the “ChangeDestination” function. You would setup the “ChangeDestination” function inside your button BP to get a reference of the Gate and set the Gates Destination Variable to the Buttons one.

That’s all. If you make the Destination Variable of the button Editable, you can change it after placing the buttons by clicking on them and changing the value in the right options window.

Thankyou for all the responses, I’ve tried to get all the info I can, it may be that I’m working myself up and it may be very simple.

15470-buttons.png

These are the buttons with the teleport door in the background. The button are placeholders for testing/practice.

This is the trace, from following online vids/guides (this is in the player controller blueprint)

The button blueprint, with a function that I gave up on (this is stored in the actor)

15483-teleportbp.png

The teleport blueprint (in level blueprint), it used to pick up a variable for the target from a onactorbeginoverlap but I’m trying to use buttons now and its failing.

So a very quick what I’m trying to do. I’m trying to have it so that when a player clicks either box (button) it will change the teleport destination. I made it work with a onactorbeginoverlay with a trigger volume but I could make that all work from just the level blueprint. Now I assume I have to trace to the button when “left mouse button” is clicked. Trigger that button and then send that to the level blueprint to change the Teleport destination. Am I going the wrong way about this?

Oh and ignore “Stargate” references, never watch Stargate while working with Unreal Engine 4 lol

I sort of worked out something before your reply, but you made it clearly for my muddled brain. However when casting to the button blueprint I can’t receive the correct info from hit result. Do I have to create a function inside the button blueprint to be able to output that casted input? As all I get when watching is “out of scope”

What exactly do you want to debug here? Out of scope normaly means that the variabel can’t be debuged at runtime when you try to show the value inside the BP. If you want to somehow debug your Actor, you could take the Hitactor and print its name. There should be a method to get the display name and that you can plug into the print node. I don’t even know if i understood what you want.

Normaly you are still able to cast the hitactor. To simplefy it:

The Hitactor is just the ACTOR (nearly everything is an actor in UE4 as long as it is in the scene), that you found with the Line Trace. I guess you know what a line trace is. You need to specify the Object Channel when tracing or the visible channel. They must match the one your Button is of. If you buttons is of type StaticProp or something, than you need to trace for StaticProps. You can define this in the Mesh Properties of your Component.

Now if you hit an actor, you will get every actor of Type StaticProp. To sort out your Buttons, you need drag the HitActor to a blank space inside your blueprint and type “cast to”. After that, it should show some autocomplete things. One of it should be your Button BP. Take that. Now this cast node has a Return value. Take this and also drag it into an empty space on your Graph. Now you can search for your Function that you definied inside the Button BP.

Make sure the upper right check mark is set to context or something, so that it shows you the propper results.

Hm ok. But this HUB is for questions. You don’t take my time. I wouldn’t answer if you hadn’t the time.

But i recommend you to watch more tutorials. Normaly you learn pretty much from just watching tutorials.

Its ok, I’m struggling to explain and I’m taking up more than enough of peoples time. I’m much further along then I was before which I’m very grateful for. I will keep plugging away at it.