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?
asked Jul 13 '17 at 04:52 PM in Blueprint Scripting
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
Follow this question
Once you sign in you will be able to subscribe for any updates here