Hi I am having trouble understanding why my blueprint is not working. Essentially I am trying to make a puzzle where you press button in a sequence. To check that the buttons are being pressed in order I am checking what the last pressed button is. The screenshot below is the blueprint on the orange button and I am trying to access a variable stored in the green button blueprint (boolean which shows if the green button has been clicked or not) Can anybody help me with this problem please?
I assume “Green Button” is not of type Button_Puzzle_Green because the cast gives a warning. And if it is of that type, you don’t need a cast.
The Warning should mean that GreenButton is already of Type Button_Puzzle_Green. So you don’t need to cast.
What is GreenButton at all? Is there a reference filled into it or just an empty variable?
Sorry for not including that information before, Green Button is a reference to an actor. I’m trying to cast to the Green Button actor so I can access the “Green Has Been Hit” boolean.
If the Green Button variable is already from that type, you don’t need to cast you can just drag a nod out of it and access the Boolean.
The thing is, did you actually save any Actor to that Variable? Reference Variables are empty by default.
You need to get a reference to the actual Instance of an Actor into it.
Example: You can have 10 PlayerCharacters in your Level. A reference of type PlayerCharacter will be empty until you reference of the
10 PlayerCharacters in it. If you do so, you can then access the variables/functions of that specific Instance that you saved.
So if you have a boolean on the PlayerCharacter Class, called “bMyBool”. This can be “TRUE” or “FALSE”. Every single PlayerCharacter has that variable
and they are NOT linked. So if you retrieve this variable from one the of 10 instances, you will get that specific boolean and its current value.
Thank you both for your help, the issue was not saving the actor to the variable. I thought I had done this already but realised I had not after you reminded me. Everything is working now, thanks again.