Download

Accessed None Reading Property

Hi,

Every time I try to get a variable from another blueprint class it needs a target (which I already knew). However, when I give it a reference variable it never works. It just comes back that the reference is empty. I tried using an IsValid? node and that didn’t help me. I tried casting as well:

834e9209ec15e817f3b10f563b7020c47aecfb98.png

Lastly, I tried setting the reference variable to expose on spawn and editable. I even tried doing all of these at once to no luck at all. I’ve searched as much as I could and everywhere I look I see “Use an IsValid? node”. If somebody could help me out here it would be really appreciated. I can’t finish my game with these errors.

@nic2017

I think you have the wrong target. Try to replace the “Get Player Controller” with “Get Player Character” or “Get Player Pawn”. This should get you the right actor.

Hi DarkGodsLair,

Thank you for the quick reply. I replaced “Get Player Controller” with “Get Player Pawn” and it works now. I’ve been banging my head on the wall for the past week trying to figure this out and it was as simple as 1 node that I had to replace lol.

Well… It’s like you called the wrong person. Instead of calling the fire department, because everything burns around you, you called a demented old woman, who likes cats and can’t hear any word you are saying :). It’s very helpful :D.

Have fun with your project! :).

Thanks for the laugh lol. I have one more question. What would I use for casting to a widget? I’m sure it’s not the same.

@nic2017

Actually, it is much easier. You don’t really have to cast to a widget. Normally to create a widget and add it to screen, you use the “Create Widget” node:

3cebd7d2beda4808861621703045409c.png

The “Create Widget” node references itself, so casting is not necessary. If you want to make it more convenient, you can even promote the Return Value from the “Create Widget” node to a variable :).

What I meant was casting variables inside of widgets. For example I have 2 widgets. The first one is “Inventory” which holds an integer variable “Money”. The second widget is “CasesScreen” and in this widget I want to get that “Money” variable from the “Inventory” widget. Obviously, since they are 2 different widgets I need a reference for the “Money” variable in the “CasesScreen” widget. Just like the first time, I also need to cast the reference so, it’s not empty. So, to cast, instead of using “Get Player Controller”, what would I use?

@nic2017

This is pretty easy too. We can’t just blindly put something into the cast target. We need the right type of object, so we need to scan our game environment to get a reference:

0a88ccdda271442d8485e8f6a72937bb.png

Out of the 2 months I have been on these forums, you have been by far the most helpful out of everyone :D. Thanks for you help.

I spoke too soon. Now when I pass from 1 widget to another in the same session it doesn’t get the “Money” variable when I go to the 2nd widget. I set up the casting in all of the widgets. Not sure if you quite understood me so, here is an example. If I play the game and click over to the “CasesScreen” widget the “Money” variable works fine but, then if I go to another widget, for example “Market” (I set up the cast in this widget also), it won’t show the value of the “Money” variable.

@nic2017

I tried it now with 3 widgets. I noticed something strange. I created 3 widgets but I just added one of them to the viewport. When I didn’t add the “Money” widget to the viewport, it couldn’t get any variables, because the cast failed.

Could you maybe plug a “Print” node to all widgets “Cast failed” execution node and then report, how many are sending something back? I need to investigate this issue. It is the first time I noticed this problem.

I’m not quite sure what you mean by “Could you maybe plug a “Print” node to all widgets “Cast failed” execution node and then report, how many are sending something back?”. All I know is it fails after creating the second widget like I previously stated.

I confirmed that it has something to do with the actual widget you have active on your screen. As long as the widget isn’t added to the viewport, the widget doesn’t exist (although we created it already). Hence there are no variables you could get from a widget, which doesn’t exist or doesn’t exist anymore. I reckon you remove your current widget, when you switch to another widget? This would explain a lot. Basicly the “Construct” node will not run, before the widget is added to the viewport. Even when you add a widget later to the viewport, it won’t run the construct. Putting your stuff in event tick works, but this is not a good approach at all performance wise and isn’t good scripting practice either.

You know what? Tell me, what you want to do with this. Looking at it now I would advice against putting any kind of values, which change into the widgets. We need to get the values from something else. Maybe a centralized core blueprint.

I do remove the current widget when going to the next. What do you think would be the best approach? I don’t have a lot of experience with this stuff, so it’s a little bit hard for me to understand it all.

@nic2017

To be honest: Just run it through an actor, which is not visible in game. It is kind of a dummy blueprint with no functionality. Create there your variables and your important stuff. When the widgets need to retrieve information they need, you can get this information from your dummy blueprint. You only need to cast to 1 and the same actor always. The only thing you just need to do is updating your dummy blueprint (or rather the variables). This is what I mean with “Centralized Core”. This blueprint is responsible for every variable and changes, which you apply to them. You can even change the dummy blueprints variables from your widgets, if you want to. I tried this functionality by having 3 different widgets, which ran different changes to the variables. Everytime I switched, I got the right result:

7e025eccf4d1487695496d00a2679934.png

adf6204a9c8c45c9ace87ba90618f767.png

f4be4aec80b345658d5d78a743594db467201de9.png

abc174f3400449ceb5eaa42e15956f2c.png

b62dd06216574529946973821c346e01.png

The “DummyBlueprint” is just an empty actor blueprint with variables in it. You only need to drag one of these into the level and then only call “Get All actors of class” from the widgets, instead of using “Get all Widgets of Class”. I hope I’m being of help somewhat :).

It works now :D. Thanks for your help and if I ever get any errors pertaining to this I will PM you. Thanks again!

No problem. Just shoot me an PM, if you get lost :). I think this is better than having a bunch of widgets cross connecting and fail.

Hey,

I don’t know if you got my PM this morning. Lately, my PM’s haven’t been going through. This isn’t an actual problem with the casting. It’s a problem with saving and loading variables from a widget to my character. Just a quick explanation of what’s happening. Basically, I want the player to be able to save a bunch of variables that is stored in the character blueprint on the click of a button in a widget, when they click this button to save, it also takes them to the main menu. Which from there they can then load that save game from the click of a seperate button. Before I casted, I was getting the error that it accessed none trying to read the property and I thought once I fixed that it would work just fine. However, it still doesn’t work (I don’t get that error anymore btw). Here are some screenshots:

Also, if we can talk over email or something that would be better :stuck_out_tongue:

@nic2017

To be honest, I never used the savegame feature. I can’t say for sure, how it does things and how it saves the stuff. Normally if you change levels, the character and all the game environment will reset itself to default values. I imagine the savegame feature in the Unreal Engine will pass information at level start, when the savegame was loaded. What normally helps me atleast is making a backup of my project and then changing things inside my duplicated project. I open the blueprints, which are essential for my stuff I want to do and then disconnect the content. Try to dissect and simplify, what you want to do. Create the functionality you want to do, but with minimalistic content and minimal variables, so you can see, where things are falling apart.

The only thing I can offer you is that you send me your project so I can look at it. Even if the screenshots are helpful, I can’t really make out, what exactly happens. I noticed some pitfalls there, but I can’t really say for sure, what is wrong :).

My Mail: darkgodslairgames@gmail.com

PS: Your PM got through. My grandfather celebrated his 88 year birthday, so I was mostly offline today :).

Ok, I will send you an email with the project (a lot of things will be taken out of my project due to it being a big file but, I will leave the necessary things). Sorry to bother you if I am. I just wanted to double check if it went through :P.