How do I use a key press to play a UMG animation?

Well, I know for sure that you can use keypressed events inside UMG, because I’ve done it before.

  • Make sure the correct set input mode is used.
  • Two (out of many) options for you: try OnKeyDown in UMG
  • Forward the key presses from Player Controller to UMG.

Hello I’m having some trouble when I try to play a UMG animation with a key press, in this case I am trying to use the “F” key. I tried using a function inside the UMG and calling it from the level blueprint, and I have tried (and probably misunderstood) using event dispatchers. From what I understand you can’t use keypress for firing events in the UMG event graph.

The question put plainly is, how do I play my UMG animation with a Keypressed event in the level blueprint?

Thanks!

Joe

Focus is tricky with UMG, and it’s bugged in 4.11 on top of it.

Have you set a break point and are you getting the keypress?

You can call the function directly. Make a variable type Widget on your controller and set it when you launch your UMG. On the event cast it to your specific type that has the function, and call it. The node to play the animation will be in the function on the UMG.

To test that it is working, before figuring out the input, call the function right after you add the widget to the viewport.

This should be possible in 4.10. In 4.11 the keypresses are messed up with setting UI Input and need to wait for a fix.