How can I make my character move left or right when I touch and hold my android device and go back to center when I release the touch?
Hi, I make an android game. I want to make my character move left when i touch and hold the left part of my android device and move right when i touch and hold the right part of my android device. When i release the hold i want to make it back to the center. But i dont know ho to do it. Can anyone help me ?
I can think in 2 diferente aproches, one is setting one collider for each region, left and right, when a touch happens cast a raycast to check which side the touch is happening.
The other one is to set a transform in the middle of the screen and check if the position of the touch is on the right or left side of the middle transform.
As for the movement just make a sort of state machine on the update, where if the user is touching move to the touch side, if not move to the center.
Your answer
Follow this Question
Related Questions
Own player controller script let the view wobbles but why? 0 Answers
how to make my character move up and down in android control (endless runner game) 0 Answers
Touch Controls without virtual joystick 0 Answers
Gyroscope Controls for FPS 0 Answers
How do I make my movement script move the character UNTIL I let go of the key? 1 Answer