Widget can not receive event from PlayerController

i set this.
QQ图片20211208111733

But not thing happen. I can bind evnet manually like Bind event to… That works.
Why auto bind not work?

Widget is not appearing on the screen?

pristring not call.
On Any Key Dispatch not trigger.
BInd manually work fine.

What’s auto-bind, firing an event off a reference? Are you trying to intercept PC input because you’re in the GameOnly mode?

edit:

I believe that the auto-bind happens earlier - during onInitialise (as it should), but at this time the reference to the Player Controller is not yet valid, so no binding actually happens and it fails gracefully without telling. The ref gets set a bit later, when the widget is actually Constructed.

You could bind during Construct inside the widget itself:

image

That’d work but it’s still manual. And an alternative is, of course, this:

Messy when compared to what your expectations are, but it works. Since the widget is fully dynamic, you may need to rely on the manual bind.


It’d be a different story if you had something sitting in a hierarchy from the get-go, ofc.

yeah,thanks for reply.
auto bind means no node Bind Event to…
instead of use


That will keep node less than use manual.
But I don’t know Why this not work.
May be the PlayerController is not initialized, Even I use Widget Construct Pass a Ref.

Read my message again, I believe I explained why it does not work. It’s the order of operations. During Widget Init the PC reference is not yet invalid - this is when this binding would automatically happen. For a dynamic widget, it must be done later.

May be the Player Controller is not initialized, Even I use Widget Construct Pass a Ref.

No, it’s the other way round. The Widget is not ready to create a bind this way. Widget fires Init first and then (Pre)Construct:

If you do not believe me, try to print the passed PC reference during widget’s OnInitialise → you’ll get nothing. Print it in Construct and it will work. But binding happens during Init afaik.

OK, thanks for your explain. I just hope it get work.
because, this blueprint looks clean and easy to understand.

1 Like