You never set the variable ‘player’ prior to using it. Hence the ‘accessed none’ error. Check out video #27 in the link below. Also check out #25 for more information on creating references to various objects/actors. In this case referencing the player shouldn’t be very hard.
Also, try adding a delay (for testing purposes) after the main HUD construct and before calling the init function. Want to see if perhaps the passed in reference wasn’t valid before using it to pass to the display widgets.
All Player and MainHUD variables are set as exposed on spawn and instance editable, so passing them in the CreateWidget node should set them with no need for having to do it manually during the Construct event, from what i understand?
Unless i’m mistaken on that, i see no reason why the player would be valid in the MainHUD (if printed) and not in the CombinedDisplay
it initializes fine and has no reference to the player within it (not yet anyway, as the menus arent populated with player data yet and not directly (only via its MainHUD reference)) so i fail to see how it would be relevant
Yes I was asking to be sure it wasn’t that widget throwing the error. A simple print string won’t tell you what blueprint fired off that event given you have multiple and since we are dealing with initialization issues I thought I should ask to double check if that widget wasn’t the issue because I could see how things would error out if certain functions executed before others completed. Anyway, my next thought is add something to the print string so you know exactly which one is printing true and which is false. Like “main HUD widget” appended to the true/false output
Then you can tell exactly if it’s the construct giving the false or the function. The above post is correct though the string prints new lines at the top of the screen.
what is your point here? i know which print did what, that’s why i posted the question to begin with. there is nothing asynchronous going on here from what i understand of unreal engine… so it’s baffling.
I don’t know if you mean to come across this way or not but when you say things like “I fail to see how this is relevant” and “what’s your point” it feels as if you are irritated with me for volunteering to try and help you work through this problem. As the individual not experiencing the issue and not in front of your computer I will tell you that a lot of times people run unto issues that are quite simple to fix had a fresh set of eyes looked over the entire thing. Unfortunately it is impossible for me to do that on this end of the screen. So I try and wall you through how I troubleshoot things. It may seem like you’ve dotted your “I’s” and crossed the “T’s” until I ask you to print a string or put a delay in etc. So the fact that none of that is working is actually useful info for me to know as I process this issue with you. You’d be surprised how many times I’ve come up with every possible solution I can think of, spent days on a problem only to have the OP post something that says “turns out I forgot xyz”. So while all of this may seem annoying to you when it doesn’t work I appreciate you confirming these things for me. Now that we got that out of the way, the only reason I know why something would be “invalid” if you haven’t made any silly errors would be the player character is actually destroyed at some point in between the main HUD and the display initializing. Which would be odd hence why I am trying to find a less odd reason for this issue. But for completeness sake, any possibility your character enters a state in your game where he would be killed or something happen to him that could potentially invalidate the variable reference?
i, too, am a programmer by trade looking back on it, it does come across as a bit snappy.
There shouldn’t be, this is entirely new project with the presented code being about half the code there is in the whole project (the other half being a basic item implementation, but only classes setup, no actual items got initialized yet nor are there are any instanced in the testing map).
Haha all good my friend. Just wanted to keep this cordial Another thought, have you tried replacing the variable with a direct reference from a cast node and see if that fixes the issue? Could be some issue with how the variable is being passed through the multiple sub widgets.
I’ve been able to create a display for my stats that isn’t structured quite like what i’ve initiality imagined, though i have absolutely ZERO clue as to why the approach i’ve taken now works vs the one that initially did not :|… (i create the displays directly in hud instead of having a CombinedDisplay class and put them into a dictionary for purposes of systematic updating (i have a ModifyStat event on my Player that is supposed to be the main event that is fired to make sure everything is kept up-to-date whenever health, energy and such change) and that apparently works…