How to make player move the way the joystick is moving [Example Shown]

Im trying to make a fangame, but having trouble moving character like in the example, I looked through every post there was like my problem, but iim still not having any luck, I tried many times to work it through myself, but nothing worked, cause there was multiple errors and multiple things i did not want happening, if anyone can help, can you please help me with this situation. Thank youalt text

Hi there,

You have to save into a variable the initial position of your joystick (initialPos), then in your Update method, you will have to get the direction of the movement. Simply by subtracting the initialPos to the newPos, you will get a vector going from the center of the joystick to the current position of the joystick.

So there you have your movement direction. Apply it to the rigidbody velocity, or translate it via transform, as you want to generate your movement.

Knowing the direction of the movement you should be able to move your character through that direction. And as you are doing this in the Update method, you will get updated your movement direction every frame, as the joystick moves around.

Hope it helps.