I’m seeking assistance in implementing clickable viewport arrow buttons for character movement in my Unreal Engine project. I’ve created a User Widget blueprint with four arrow buttons and would like to utilize them to control the character’s movement in the desired directions.
I’ve attempted to connect the button events to the character’s movement logic using custom events, but I’m encountering difficulties in establishing the necessary connections. I’ve explored various resources and tutorials, but I’m still struggling to implement this functionality effectively.
Would anyone be able to provide a detailed explanation or step-by-step guide on how to connect the clickable viewport arrow buttons to the character’s movement logic? I’m particularly interested in understanding the proper use of custom events, event dispatchers, and input bindings in this context.
Any insights, suggestions, or code examples would be greatly appreciated. Thank you in advance for your valuable assistance.
if its a single player game you can just use the getplayerpawn node then cast or interface to it and tell it to add movement input in the desired widget direction
It’s a single player/ first person project. Thank you very much for your reaction. It sounds very simple, but I’m having trouble understanding what you mean. If or when you have some time, can you please give me some more details.
Hello Auran,
it’s almost working. I tried to do what you told me. Now, when I click and hold the forward button on the viewport, the character goes forward a little bit and it stops. Now I’m trying to make it keep walking forward as long as I keep the button clicked. Would you be so kind to take a look at my code and maybe help me out?
Derick Pereira Silveira
yep the clicked event only fires once so what you can do is used the pressed/released events.
you could use a timer but for simplicity lets use tick. on pressed set float variable to 1. on released set it to 0. each float value will correspond to an axis.
move the add movement input to tick and use the floats to make a vector. so if nothing is pressed it’ll be 0 and not move.
in the example you dont need the cast either to save performance
Unfortunately, I was celebrating too early. It’s almost working, the arrow buttons are
functioning in the right direction. However, as soon as I turn the camera, the arrow directions get messed up because the movement iss not following the camera.