Announcement

Collapse
No announcement yet.

Widget not receiving event from referenced blueprint variable (other blueprints are)

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

    Widget not receiving event from referenced blueprint variable (other blueprints are)

    Hi there, first time poster.

    I've just started with Unreal and I'm a bit stumped with this one.

    I have a blueprint - let's call it JohnCarpenter that dispatches (calls) an event - let's call it TheThing.

    I know TheThing works because A) I have bound events to it in other blueprints and they work, and B) I added a variable reference to JohnCarpenter in a blank blueprint and added a TheThing event using the details panel (the big green + button), and that works too.

    I also know my widget's reference is good, as for a test I queried one of JohnCarpenter's other variable states in the Tick update, and that confirmed that its reference to JC was valid and working.

    But, my TheThing event in the widget just isn't firing. I added this by using the green + button from JC's reference in the details panel, same as the blank blueprint that worked.

    I have compiled everything, saved everything, but I am stumped. Can anyone help?

    Thanks

    #2
    How are you triggering the event in your widget? Button click? Try a print string just before The Thing event is called in your widget to see if that is even being triggered.

    Also screenshots would be super helpful. The code names are a bit confusing, at least for me. Calling them by what they're actually called, Actor Blueprint, Widget, Custom Event, etc., would be more helpful I think.

    Comment


      #3
      Thanks for responding. Apologies for the code names, that was my 4am brain thinking it might make the question more fun to read whilst still being legible.

      The widget isn't triggering the event, it's receiving it.

      I believe I've solved the problem, though. The reference is set during the Widget's lifetime, i.e. it's not set when it is created, and in this case it doesn't seem to trigger.

      I made an empty blueprint with a null reference to the Slot blueprint, set up the event receiver there, and added a delay of 5 seconds on BeginPlay, after which it assigned the reference to a valid Slot object. The event did not trigger even after the reference was set.

      However, if I assigned the reference directly using the details panel in the editor before launching, the event worked fine.

      It seems to require that a reference exists when the blueprint is created for the event to work out of the box. I think I will have to manually bind my event to make this work.

      Thanks for the help.

      Comment


        #4
        Glad to hear you've got it figured out. I'm still a bit hazy on exactly what you were trying to do, but when I communicate with widgets, I usually create a reference variable in the widget of type Actor (or a specific BP if I have one, like MyPlayer_BP) then expose it on spawn. So when I assign the widget to a player or screen or spawn it in then I just hook in the actor who owns it or is running it. Then you've got a reference the moment the Widget is created and can bind it's local variables to anything you need access to. I then use a custom event on the Widget I usually call "Update HUD" or whatever and call it whenever a visual change takes place.

        I'm pretty new myself, so this is probably a bad way to do this. lol

        Comment

        Working...
        X