How do I control a character through a widget, without input?

I’m just starting to figure out unreal engine 5, and don’t scold me too much. :confused:

Now I’m doing my first project, a 2d game on a mobile device and I want to make simple control of the main character. So that it can move right and left on the same axis. I don’t like the joystick that unreal offers me.

As I understand it, I need to create a custom event in the character and then, in the widget, access it through the button. But how to make a character move through a custom event…I can’t understand

Sorry for my English and for the possibly stupid question. Thanks a lot for the answer (if there is one:( )

1 Like

Hey fourvleg, welcome to UE forums!

Question isn’t stupid, and your English is very good :slight_smile:

Make a blueprint interface and the widgets that control movement on a canvas panel, add the blueprint interface to the player and the widgets in class settings. Send a message from the widget to the player on event button pressed, and make the blueprint interface event connect to your characters movement.

Some advice for doing this method:

Some self explanatory nodes to use will be “add widget to viewport”, “on pressed”, and your custom BPI function events

Get a player reference when the widget is constructed and store it in a variable (right click promote to variable on the pin)

Use event pressed, not clicked for mobile. Make sure to learn all the differences for button events if you do not know :slight_smile:

Here is a good learning resource for blueprint interfaces

1 Like

Hey tolacipeetahi, thanks a lot for the answer and useful info. I’m going to try everything now, but I don’t understand how to make my character move correctly. Thank you very much again!

На данный момент у меня такой код. Но мой персонаж уходит под стену…

The system you posted does not fully utilize UE5’s built in movement and input system, meaning it is over complicated and will cause you more headache than it’s worth.

I recently created a project for someone else on this forum for them to learn from, I will share all of its details with you here so you can do the same :slight_smile:

Create a new top down project and navigate to here, mine is modified and will be different from yours, mine is set to work for using WASD or arrow keys for moving, yours is set up to move the character with clicks.

All of these IA’s (Input actions) are utilized here, in the IMC. The IMC (input mapping context) is a collection of IA’s that you can assign to a player controller or player controlled pawn/character.

You should learn ALL of the options under value type drown down in the IA

In the IMC, you can see the IA’s all here. Feel free to create/add more. You should learn about the negate modifier in the IMC

The IMC is applied to the player controller here

And then added to the player controller with this code

This gives you access to new events that trigger on your input, these triggers are based on the settings you configured in the IA and IMC.

image

If you need any more help, feel free to ask :slight_smile:

Tip about movement component

You should generally always use the character movement components that are provided by UE5, whether it be characters, or pawns. Modifying/creating movement components is way, way too much work. Leave modifying this to experts in the field (decades of experience to be honest), we can achieve everything we need without doing this for practically any game :slight_smile:

And do not worry about your character going through walls at the moment, it sounds like you are not using the proper movement component base that UE has provided, all the things it does for us is too complicated to explain in anything less than a book :sweat_smile: