How to modify public variable with blueprint

Hello !

I’m new in unreal and i have a newbie question :

I made a public variable and i’m able to change it in “real time” by myself but i’m trying to change it with an external blueprint.

How can I access to and modify the public variable ?

Thanks for your help ! :slight_smile:

Hi DavidManfredini,
If I understand you correctly, you’re looking to edit a variable from Blueprint #1 in Blueprint #2. The best way to do this would be to cast to Blueprint #1 from Blueprint #2’s event graph. When you cast to another blueprint, you can access all of it’s public variables and functions.

All you need to do is to add the node (Right click in the event graph and type ‘Cast to’ followed by the blueprint’s name) and then in the drop down box inside the node, select the blueprint you’d like to cast to. After that, you can drag from the ‘As blueprint name’ pin and type ‘Get’ or ‘Set’ followed by the variable name to access it.

I hope this helps!

Matthew Clark

Thanks ! This helped a lot ! :slight_smile: However i’m trying to change the value in the editor, not in the blueprint.

I made this, but i was not able to change the value.


Sorry if it’s a stupid question :stuck_out_tongue:

Make sure you get the specific actor in the level that has the variable you want to change, and then its subcomponent.

If you only have one actor of that class in your level, use a Get All Actors Of Class node, followed by an Array Get node (value “0”). That gives you a single Actor output pin with access to that specific actor’s functions and variables.

You can probably connect that to a “Set Trace Length (HoverComponent)” node through the context menu, or first get the Hovercomponent and then set that variable.

Have you tried looking at the value while simulating? If you start simulating (Hit play in the editor) and hit V a couple times, hit Shift+F1 to regain the mouse cursor and then, without stopping the simulation, look at the values, does it show a difference?

The values shown in the editor are normally the default values that the variable will have as soon as the simulation begins, so anything set up in the event graph will only affect it while simulating.

Hi DavidManfredini,

We haven’t heard from you in a while. Are you still experiencing this issue or have you figured out a solution? If you have, please let us know for future users. In the meantime, I’ll be marking this issue as resolved for tracking purposes.

Have a nice day,

Matthew Clark