How to I get a variable from a different Blueprint?

I’m new to Unreal and making a test game just to get the hang of things. Basically, the game starts with the player listening to a AI character making a speech. At the end of the speech, the player has to decide whether or not to flip a switch. If they decide to flip the switch (by pressing the designated button), there is an animation that the switch plays that shows it moving from one side to another.

I need to make it so that pressing the button before the AI character is done with his speech does nothing. Then, once the AI character is done, pressing the button should make the switch animation run.

I’ve tried going about this in every way that I can imagine. From what I’ve been able to gather through my exhaustive search, the best way to share variables between blueprints is using casting. Thus, the best way that I could come up with is for the AI character’s final blueprint node to be a simple boolean variable “TimeToEnableSwitch.” This would indicate that his speech is done. Then, in the player controller blueprint, I’d have the button-pressing event connected to a “Cast to AI Character” which would then allow me to “Get TimeToEnableSwitch.” Finally, I’d connect that to a Branch → if it were true, then the switch should play the animation, otherwise do nothing.

The problem is that I don’t know what I’m supposed to connect to the “Object” input node in “Cast to AI Character,” and when I try to compile I get errors saying “The type of object is undetermined” and “The current value of the object pin is invalid.”

Can anyone help me find the right node to plug into the “Object” input?

For the future I recommend watching this video, which is the bare minimum you have to know about Blueprint Communication and Casting. The object pin is a reference to the AI Character and by casting you basically get access to all the functions in your AI Character. This reference of your AI Character is usually saved when you Spawn the AI or if it’s already in the world by dragging it into the level, you can make a reference in your Level BP. If you didn’t understand what I said, please make sure to watch the video as it will give you a solid understanding of casting. <3

Thank you, I really appreciate your help. However, this specific instance seems like something that should be pretty simple to implement. I know that I should watch the video to gain the bare minimum knowledge that I will definitely need for the future, but I was really hoping you could pass along the quick fix just so I can get this to work for the time being. Please and thanks!

But I did give an answer, you need a reference of the AI Character that you get when spawning the AI or from the Level, or did I miss something?

Thanks for your help. I don’t know exactly what you mean by “reference.” I’ve tried connecting “Get Owner” to the “Object” node (that’s what intuitively makes sense to me) but it’s not working. Where do I find this reference? And when I drag off a pin from the “Object” node, what should I type in order to select that reference?

What Ninjin means by refference is a individual instance. You can have 100 Ai Characters in the Scene and a refference points to exactly 1 of them. In your Case the AI you currently Speak to. But the refference has to come from somewhere. Overlaps return you a Actor for Example and you use that Actor as Input for a Cast Node to find out if the Overlapping Actor is a AICharacter type or something else.

We dont know your Setup so we cant give you a direct Answer. But the Video covers most essentials. If you Spawn your AI dynamicly, the one who Spawned it has the refference and can Send it to others he has or can get a refference to. If you simply placed your AI In the Level than you can select it->Open Level BP->Rightclick and add refference (No Cast needed btw its already the right type). You Level only knows about things you Placed before you start the Game so be aware of that.

Thats what a refference is. A Pointer to a Specific Object that exists. Without it you cant Communicate to that Object.