I’m following this tutorial https://www.youtube.com/watch?v=zNrZoox7pkE Which is calling a widget button press event to another blueprint. As part of that tutorial he is creating the widget and adding to the viewport in the other blueprint. I can’t do that with mine because the widget is already created because its a 3d widget placed in the game. This is the code I have but I get the following error.
Blueprint Runtime Error: “Accessed None trying to read property PlayerCardBP”. Node: Bind Event to On Start Button Clicked Graph: EventGraph Function: Execute Ubergraph BP Wave Bar BP Child Level 1 Blueprint: BP_WaveBarBP_ChildLevel1
I don’t have it set anywhere. in the first screenshot I’m using a reference to that BP and plugging it into the target of the bind event. Should I be setting it somewhere also?
If you haven’t set anywhere then all you have is a variable of type BPPlayerCardSelected with a null value. That is what Blueprint Runtime Error: “Accessed None trying to read property PlayerCardBP”. is telling you.
You need to somehow set a reference of the specific instance to that variable to actually be able to use it. E.g.: lets assume there are several cards, how can this class know which one has been selected?
Ya I have gone through those videos. I was aware of most of it but it doesn’t address the issue I’m having. So I’ve set the widget like you suggested in the second screenshot and the widget itself is in the first screenshot. I’m still getting the accessed none error so not sure what is wrong.
This is worse. You’re nullifying the reference. A variable is not a widget, it’s a mere reference to an existing one. A variable can only tell the engine where the widget sits in the memory.
Imagine there’s 10 widgets, which one do you mean? Where is it? Where was is created? Who owns it? Is it perhaps one of the widgets we see in the hierarchy on the left? Is this a widget created in the player BP? Someplace else?
I can’t do that with mine because the widget is already created because its a 3d widget placed in the game.
That’s cool. Which blueprint owns the widget component?
This is what I thought also but
pezzott1 said I needed to set it so I said I’d give it a go even though I didn’t think it world work. When you which which BP owns the widget. What do you mean by that. Do you mean which BP do I have the widget added through a 3dWidgetcomponent then the answer is this one that I have placed in the level.
Need to ask since you called it PlayerCard_BP. Not 100% sure what it really refers to. Could it be the widget 3dWidgetComponent in the first pic instantiates? Am I close?
Ya thats right the widget that has the button we are clicking is in the 3dwidgetcompontant in the 1st screenshot and the actor in the second screenshot is trying to call that button click and both are in actors are in the level
The above translates to: when the Start Button is clicked in the PlayerCard_BP's 3dWidgetComponent's Widget (PlayerCard BP) (what a mouthful!), we call the Custom Event in the WaveBar_BP.
Another way, using a hard reference inside one of the BPs:
Ahh I understand. I thought you were using the dispatch event I created that called when it was clicked. I can see it is its own event that you can call.
Ok so it doesn’t work for me but I think because it gets more complicated than I thought. This originally was a 2d game template that I am converting to VR. so I had to remove the traditional way of adding a Game UI by including a 3d widget. Technically the BP_Playercardselection widget is in the 3dwidgetholder but it is a part of another GameUI widget that is being cast to the 3dwidgetholder by the player controller.
You need to be mindful of order of operations. Since you’re doing this in the player controller:
The widget may not be ready to fetch from the component. Is there a reason why you cannot simply set the widget on the component in the traditional way?
Ideally, rethink the way you reference stuff. Worst case scenario, reference it in the the PC and have any other entity reach out to it and register delegates there.