Trouble reffering to variables/blueprints between blueprints/mycharacter

Hey guys!

The last few days I’ve been struggling hard with making the easiest thing possible which is:

Reading out a variable from one blueprint in the other and use this to trigger something else.

You’d say this is the easiest thing ever! Just make an object variable with the blueprint you want to target and get/set like in the basic tutorial but every time I do that I get the error the variable is empty even though it’s a bool. I feel like I’m missing something really easy which nobody talks about due to it being so obvious but I don’t see it!

So obviously I do something wrong! I’ve tried my hand in casting but get the same issues none the less. I’ve googled around and found people with similar problems but the projects and the solutions were either out of context or too complicated for me to grasp so what I hope to achieve with this questions is that somebody can help me on the most basic way possible so I can continue. I don’t need to make very efficient scripting so if there is a simpler way but less nice please use that. Once I grasp the basics I can go deeper.

So how do I make the following work in the easiest way possible without me getting the error that the variable is empty? This should be a piece of cake for you guys but for me it somehow doesn’t work and it frustrates me to no end!

I have a box in the room (basic blueprint with box mesh and nothing else in it’s components) and my player character that comes standard with the project. My project is a blueprint project and the rest of the room is empty but the floor. The box prints out the status of a bool I set in my character.

Mycharacter Blueprint:

I press Q to trigger the set of a bool I named TestRef (it toggles via a flipflop) which is editable

Box Blueprint:

I made a variable called TestRef (also editable) that is an object linked to the MyCharacter_C blueprint and made an event tick that prints out the status of the bool via get TestRef(blue) → Get TestRef(red) → Convert to String → Print

If I press play it prints out false but keeps doing that even if I press Q numerous times. Closing down the play it gives me the error:

“Error Accessed None ‘TestRef’ from node Construction Script in blueprint Box”

Or in other words it’s probably empty and not defined. But how do I do this?

Any help is much apreciated as it’s very frustrating being able to make more complicating stuff but not being able to make the simplest of the simple happen!

Hi StrawberryHusky,

Can you post a screenshot of your blueprints? I might be able to see what is occurring.

Thanks for the reply! Here are some screens. I just feel so dumb for not being able to do this haha. Hope the pics work! It’s all made in an empty bleuprint first person project so it’s all clean otherwise.

World:

MyChar BP:

Box BP:

Can you show/tell where/how you set the value of the TestBox::TestRef variable? Presumably that’s where the problem is - it’s not correctly hooked up to the current instance of the MyCharacter class.

I’m not sure I understand, I’m pretty sure that that’s exactly where the issue is but I’m not sure I understand what it means.

I mean that the TestRef variable in your TestBox class is probably set to the correct type (i.e. a MyCharacter object reference) but possibly not assigned the correct value (i.e. an actual reference to the instance of MyCharacter that’s in use when the game runs). So, TestRef effectively doesn’t reference anything useful when you hit play.

If you want to continue on the plan you currently have, you could probably store the correct reference in your TestBox class by setting up something like:

EventBeginPlay->GetPlayerCharacter->CastToMyCharacter->Set TestRef to that reference

…and things should (theoretically) be all nice and peachy!

Wow thanks! This is exactly the stuff I’ve been missing all this time as nobody really shows you actually have to set variables beforehand as well. For a programmer this maybe really logical but for a designer like me it’s not.

Thanks for sticking with me and my inability to see these things and helping me out! I’m going to mark this one solved for now, I think I got enough to keep digging deeper! Thanks again!