Lets say that I have a menu screen and I want that in a press of a button my character do something like jump or other thing.
I have been trying to make this work with event dispatchers but i can’t, just happens between UMG and Character, other BPs works great…so i dont know what im doing wrong, or maybe it just can’t do that conmunication?
Well maybe thats the problem… i dont know how.
from my widget im not referencing my character but the way it works event dispatchers i dont needed (well thats what i think) i just make a call from my widget button and its suposed that i bind that event in my character and reference the widget, well thats the way i was working with other BPs, but with my character it doesnt take the call…
Im receiving this error
Error Blueprint Runtime Error: Accessed None trying to read property MyWidget from function: ‘ExecuteUbergraph_MyCharacter’ from node: Assign My Event Dispatcher in graph: EventGraph in object: MyCharacter with description: Accessed None trying to read property MyWidget
For a simple solution, one button
[button] — [cast to (whatever your player is, i.e third person] input is [get player character] out as player character [jump] this feeds info from UMG to player index0 for single player,
if you have multiple buttons, then do as suggested above, create a variable of type character ref, and on event begin play cast to character and set that variable, then you can use the variable for each button or function.
This is in the UMG Widget Event graph, it gets the player controller and then the controlled pawn(your character), then it casts it to YourCharacterClass(Mine is called PlayerCameraPawn) and then saves it in a variable of YourCharacterClass Reference type.
If you’re using event dispatchers you don’t need to reference the character itself, just the UI. I’m doing something similar but communicating between the UI and my anim blueprint. To get the reference I use the Initialize Animation event with a a small delay after it (maybe the UI doesn’t spawn instantly), then Get All Widgets Of Class with the UI selected in Widget Class. This will give you an array so Get the 0 element and use that to bind to the event dispatcher. If you’re using several player characters maybe this won’t work but it should work with only one UI widget. After that Calling the event dispatcher on button presses/etc works.