- Home /
Basic Character Transform with Joystick
I'm looking at some sample scripts within Unity, and modified a couple of them to be used to my liking. However, I'm having one issue with the controls on some of them. For instance, in the PlayerRelativeControl script (for Mobile devices), I can instantly change the direction my player is facing my quickly moving my thumb back and forth between the joystick's min-max axis.
This is not how I would like my player to run!
Ideally, if the player is moving the joystick left, the character would turn that direction, speed dependent on the degree the joystick is being held left. Same for being held right. Holding the joystick up moves the character, and holding it back does nothing (cannot run backwards). I've always programmed my character controllers by using Euler angles, so I would do
yRotate = yRotate - degreeTurn
to change the player's direction. However, I do not see anything like this in the PlayerControl script. Could someone enlighten me on how I could achieve this? Instead of having movement like it is in the Penelope demo, I'd rather have movement that's more similar to an actual running person. Or Mario 64 ;)
For an idea on how the axis values work:
X-Axis:
-1 (Fast Turn Left)
-.5 (Med Turn Left)
0 (No Turn)
.5 (Med Turn Right)
1 (Fast Turn Right)
Y-Axis:
1 (Run forward fast)
.5 (Walk forward normal)
<=0 (No movement/stand still)
I would just like ideas on how to accomplish this, or a hint. I cannot learn anything if fully coded solutions are just thrown at me! Thank you much! =)
Answer by 0tacun · Jan 23, 2014 at 10:56 PM
Pretty old question.
If there is still a need, check this out