Announcement

Collapse
No announcement yet.

Create Widget Node not returning a value for a reference variable.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Create Widget Node not returning a value for a reference variable.

    I have been working on a survival game in Unreal 4.22.3 and I have set up a UI Widget That contains the UI for the needs etc. Hunger Bar, Thirst, But when I create it in the Player character BP I get the return value from the create widget node and use it to set a reference variable but in other parts of the Character BP where I reference this variable output into the message log that it "Accessed none trying to read property NeedHudRef"

    The Survival game is supposed to be a multiplayer game. The error doesn't arise when I run it without a dedicated server with one client but when I run it with two clients or a dedicated server the error persists. I would like to know why this happens and how to fix it.


    #2
    I believe this error is coming from your server. The server does not contain or run HUD code so you'll need to make sure that code dealing with HUD elements is only executed on your clients ("Remote" from a Switch Has Authority).

    Comment


      #3
      Originally posted by Chumble View Post
      I believe this error is coming from your server. The server does not contain or run HUD code so you'll need to make sure that code dealing with HUD elements is only executed on your clients ("Remote" from a Switch Has Authority).
      I have attempted to do this but have been given the same errors in the message log saying that where i have attempted to access the variable NeedHudRef it has accessed none. I am not currently sure of the outcome of these errors and what is actually messing up during testing and so I am trying to find if anything is affected by it.

      Comment


        #4
        When you attempted that, did you at least stop seeing "Server" printing nothing to the screen?

        As for the errors, I see you have that widget reference being used on event tick. It's possible you're trying to retrieve the reference before it's been saved. One way to test this would be to use an "Is Valid" check with a branch and only print if it's valid. I don't think this is a good long-term solution but it might prove that this is the result of a timing issue.

        Comment


          #5
          Originally posted by Chumble View Post
          When you attempted that, did you at least stop seeing "Server" printing nothing to the screen?

          As for the errors, I see you have that widget reference being used on event tick. It's possible you're trying to retrieve the reference before it's been saved. One way to test this would be to use an "Is Valid" check with a branch and only print if it's valid. I don't think this is a good long-term solution but it might prove that this is the result of a timing issue.
          The Server continued to print nothing. Also when I changed the print on the tick to and is valid for the variable it printed a string to the output meaning the variable is valid.

          Comment


            #6
            And the `Accessed none trying to read property NeedHudRef` was coming from that print string node? And you now have an Switch Has Authority immediately after the Event Tick so this only happens on clients? If you could post an updated screenshot that would be helpful.

            I know I'm kinda asking you to repeat yourself but the situation you're describing doesn't sound possible. Aside from creating the widget and adding it to the viewport, is there any other blueprints touching this?

            Comment

            Working...
            X