Widget "Accessed None trying to read from property"

I have a widget that sets the static mesh of a variable static mesh component I casted to the widget, and when this first event runs, it sets the mesh correctly without issue, however in the same blueprint, when I click a widget button it gives me an error “Acessed None trying to read property Ref”. Why would it be able to read Ref earlier in the blueprint just fine and not later?
image

Hey there @SCC-VRAC! Welcome to the community!

Are you clearing the or changing the Ref variable anywhere else in the BP? It’s basically saying the reference is blank or being garbage collected upon release of that button. Is the first event working but the second not. Could we see the other locations that Ref is modified? Like where it’s set and everywhere it’s changed?

(P.S. as a new user I can only embed once per post, so i will make a chain reply.)

I apologize for my spaghetti code, I pretty new to UE and I was just trying to get stuff to work without worrying about efficiency as I have little experience with casting, interfaces, and widgets.
So I have a blueprint with public Static Mesh Actor variable, that I have set in the actor details. (Mesh 1)

In the blueprint of the actor, I casted to a child actor, converted the Static Mesh Actor to Static Mesh Component, and passed Mesh 1 through to the child actor as Mesh (sorry for the unconventional variable names.)

Then in the Child Actor’s blueprint, I cast to the Widget Blueprint and pass the Mesh variable through it as Ref.

Then when the event starts, which it starts a few seconds after event construct.
image
I realized that in the Child Actor blueprint I was referencing a Static Mesh Component that was created in the blueprint rather than the one passed through, so I changed that and now the EventBlank event line doesn’t see Ref either.

So now the issue is that I can’t use the Static Mesh Component object reference that I passed to Ref, as the output tells me Ref is Null. not sure why.

Hope this helps, Thanks.

Hrm, pop a print in when you set the ref to print that reference, to verify it’s being set in the correct place. As of right now you’re setting the Ref variable inside of the PDFMenu, then getting a mesh from the meshes array and changing the directed Ref’s SM to that Meshes[0]. So the other possibilities are that you’re spawning more than 1 PDFMenu, the Delay is causing issues (async actions on construct can sometimes be a bit funny to work with), and finally it could be that like you noticed before you were setting one reference but not referencing the correct one after.

1 Like

Ahhhh, I was creating a second instance of the widget, which was being displayed instead of the one that was already in the scene that I was casting to.
I was adding it to viewport to make sure it worked, but I just ended up testing the one that wasn’t being casted to so it gave me the error, if I just tested it with the 3D widget I wouldn’t have gotten the error. But at least I know now that this segment was useless.


Thanks for the quick replies, this saved me a lot of headache!

1 Like

No worries! It’s actually a fairly common thing. Whenever your logic seems perfectly sound, and there’s nowhere else you’re touching references, always check the external factors like if you’re even polling the right place. I’ve been doing this forever and I still do this from time to time.

1 Like