Hello. I want to control visibility of an object in the scene with another object: when I pull a lever, a button on the wall appears.
I have set up the animation of the lever, but I don’t understand how to control the buttons visibility through it.
The interaction with the lever is set inside the FirstPerson BP. I have tried to make ButtonVisible variable so that is becomes 1 when the lever is pulled, but when I’m trying to use it inside the BP_Button, it doesn’t work, since it requires another target input, and objects inside BP_Button don’t fit in.
I also tried to create a ButtonRef variable inside BP_FirstPerson and make it of a BP_Button class, which is then connected to Set Visibility, but that doesn’t work neither, and when I close the sumulation, I got error messages:
“Blueprint Runtime Error: “Accessed None trying to read property ButtonRef”. Node: SetVisibility Graph: EventGraph Function: Execute Ubergraph BP First Person Character Blueprint: BP_FirstPersonCharacter”.
Could you post your blueprint/ nodes so we can see them? I’m not 100% sure but it kind of sounds like these 2 actors are having problems communicating and this might be a reference error. I’m still fairly new here myself but ill try and help.
So your trying to get your 1st person blueprint to make the BP_button invisible. I’m assuming that you want this because you want to be able to make these things invisible in one tidy place so you don’t have to go through multiple blueprints…maybe don’t know.
However I don’t think this is the right approach.
So i’ve tried something like this and wasn’t able to get it to work. Something about a bad gateway. I don’t know if you’ve heard of interfaces or event dispatchers. But I would look those up first. I like this guy on the subject. However it’s still kinda of a mind bend. https://www.youtube.com/watch?v=EQfml2D9hwE
But lets get back to the main problem. It is infact a reference problem. I’m not professionally trained so I don’t have the proper words but i’ve encounter this before. It may seem like your referencing it correctly but your not. You need to get an active instance (again not pro so probably bad wording).
Your making a reference that can’t actively do anything. It’s kinda like trying to change a map and expecting a copy of the map to change. You can see how that’s not gonna work
This is actually a really hard subject to understand so I understand if this metaphor doesn’t make sense.
How to fix.
I would use an interfase. (But there are other ways to fix.)
However if you still want the 1st person character I don’t think you can. I was trying to make it work myself, but I think the visibility nodes are only for self references.
Sorry I couldn’t be more help. But one more thing
Remember when I said I don’t think this is the right approach?
Well I think you should have your button control whether or not its invisible. Then using interfaces or dispatchers to communicate with it and turn it invisible or not.
Also
Instead of using your 1st person blueprint to control all this stuff try doing more stuff with your game instance. Heres a video for that too.
Thank you for the reply. I have solved the issue already. Since I’m not a programmer, I’m doing this whole stuff with the help of Chatgpt, and it has not explained that public variables should be assigned manually in the outliner of the scene. That was the problem. The works now.