Hi there, im trying to make a simple player controller for a mobile game using a joystick. Ive tried both the old input system and the new input system but I cant seem to get anything to work. Ive tried for 2 days starting from the ground up and done way too much googling on how to create one but havent found a solution to my problem. Would anyone be kind enough to teach me how to set this sort of thing up? Im at a loss here and I really dont know where else to go
#Joystick in Unity 2D for a mobile player controller
1 messages · Page 1 of 1 (latest)
joystick as in two circles u can touch and drag on the sides of screen?
Yes but rather one joystick in the bottom center. I'm building a portrait game
I've gone through so many different tutorials out there and I can't get a single one to work
oh I was in hell few months ago when I was doing two circles on the sides same stuff everything is either not suitable for me or barely functioning
gl with the thread bro been there
I just did my own solution tracking initial touch location then direction where touch moved + distance towards it and acted upon it
Interesting.... That's not a bad idea
Something like
public GameObject joystick;
private Vector2 touchPos;
private Vector2 dragPos;
touchPos = joystick.transfom.position;
Then subtract the touchPos from the dragPos to get distance travelled
Something like that
Multiply the distance travelled on the joystick and multiply it to get a more accurate movement for the player itself
And then how would I get the direction? Since there isn't rotation
The player is basically in an infinite plane so I really just need to be able to move the player
In the same direction as the joystick
Let me get on pc to maybe write something up
Thanks man it's v much appreciated
yea so keep in mind im aint even good so without testing myself im prolly missing something but its a start
https://hatebin.com/qiolfpqevb with this you would have all 3 things you would need, if IsTouching is true then you can depending on what u got move ur player with CurrentDirection * DistanceFromInitialTouch but needs a clamp for max speed