Accessed None trying to read property error when trying to call an event dispatcher

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


Could you share the part where PlayerCardBP is set?

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?

1 Like

So how would I do that?

That depends how you are designing your proyect. If you want we could go over step by step how the cards are handled to try and figure this out.


I suggest you spend some time going through these. Communication is covered with sample project included:

2 Likes

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?

1 Like

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.

And they’re 100% correct. You’re just doing the complete opposite.

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.

So we now have 1 piece of the puzzle solved → the actor who owns the component is sitting in the scene, you’ve placed it there manually :+1::

Onto the next puzzle… Where is the actor below, how does it make it into the game?

Once we know that, we can connect them and they can talk.

That is also an actor that is in the level

1 Like

That should be straightforward then. One more thing, just to clarify:

  • we are clicking a button in this widget:

  • and triggering this, in this actor:


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

1 Like

Since you already have actors sitting pretty in the scene, we can use the Level Blueprint:

  • reference both actors in the LB (drag & drop):

  • have a Custom Event in the WaveBar_BP :

  • use the LB to facilitate the comms:

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:

  • in the WaveBar_BP:

  • in the scene, tell the WaveBar_BP which BP_WidgetHolder you mean:


More reading:

I get the following error when I try to attach the start button to the target


Use onClicked (at least for now):

image

Buttons already have delegates:

image

You’d add custom dispatchers if you wanted to send more data. You’re not doing it here anyway.

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.

Yup, actors and widget already come equipped with a lot of dispatchers. If you wanted to use your custom one, you’d probably need to:

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:

image

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.