For the life of me, I can’t get a simple message from my UI widget blueprint into my pawn blueprint. I simplified it so, that when you simply click a button in the UI, it should send an message to the pawn blueprint. However, it never sends it. Any help?
How are you getting the reference to Barracks in the first image?
It looks to me like you have set up a variable for it of the type Barracks BP. But you still need to Set it with the correct reference.
You could add something like this to Beginplay (or as the first thing you do in this event):
Get all actors of class (Barracks BP) → GET entry 0 from the resulting array (assuming there is only 1 Barracks BP in your level) → SET this as your Barracks BP.
After that you will be able to talk to the correct Barracks BP and the dispatcher will probably work.
I just simply create a variable and set the variable type to barracks_bp. I tried the array method but it didn’t work. The problem is most likely that I don’t set the variable properly, which I have hard time getting my head wrapped around.
Is this anywhere near?
Nope, no null reference warnings, or warnings to that matter.
I’d throw some “is valid” checks on all the object references, are you getting red warnings or any thing in your logs about null references?
Your logic seems weird to me, Your event dispatcher is in Class Barracks and you are calling a message from another class…
Event dispatchers should be : Class A have a dispatcher and by doing something I Call my dispatcher.
In class B You just do a bind to that event dispatcher, if you can bind to it it will appear on the context menu, try typing "Bind " on the search. Have you tried that?
I didn’t notice this but yeah you’re right. The dispatcher should be inside Barracks_BP, not Barracks_UI.
“I just simply create a variable and set the variable type to barracks_bp”
you need to set this variable to a valid reference of the object afterwards! maybe
- when creating the ui expose this variable and set it from the baracks bp
- on begin play or construct of the ui do a get all actors of class
- or… we need a bit mor information how you’ve setup
You are doing things the wrong direction. never ever posible to do a BIND EVENT on SELF! (tecnically possible but not useful in your case).
Normaly it’s easy peasy like:
- barracks ui has a eventdispatcher name it onClickSomething,
- in your button (inside barracks ui) onPress event CALL this event dispatcher,
- in your barracksBP maybe on begin play, get your ui (maybe getHud with a reference to the relevant UMG) and BIND to this event
done.
I think it is also possible to bind to the button Event directly from the barracksBP - but, get the easy way first.
with break points can you verify its being called and acting as expected? i use these a lot and ive never had them fail under basic scenarios
I followed your tips and changed everything, but still no luck. I think the problem is setting the actual variable, which is not working currently as it returns a none. Could anyone give simple instructions on how to reference the UI properly? I’ve tried numerous ways but I just can’t get it right.
if you provide me some space (ftp, email, git, …) I try to make a example, screenshotting this all would be some kind of ugly
I was able to fix the problem by redoing everything and taking notes of everyones hints. Main problems were setting the variables, which I was able to do using arrays, and setting the event dispatchers properly. Thanks everyone for helping!