- Home /
Question by
VladLujerdeanu · Apr 10, 2017 at 12:41 PM ·
mobiletouchtouch controlsinput.getaxisinput.touch
How to make Touch Input act like GetAxis?
I am trying to make a 2D game for mobile in which if you press on the left side of the screen the Character goes to the left, and if you press on the right side of the screen the Player goes to the right. How can I make the touch Input feel like Input.GetAxis for the PC. All I can do is make it feel like GetAxisRaw which I do not like.
This is the Code:
if (Input.touchCount > 0) { if (Input.GetTouch(0).position.x < Screen.width / 2) { direction = -1f; } else if (Input.GetTouch(0).position.x > Screen.width / 2) { direction = 1f; } } else { direction = 0f; }
Comment
Your answer
Follow this Question
Related Questions
Mobile Input - Sensitivity, Gravity Matching InputManager's Key 0 Answers
How do I move an object with my finger?[C#] 1 Answer
Possible to get touch area data? 1 Answer
Touch.ScreenPosition doesnt work ? 0 Answers
Rhythm Game - When I touch an object with mobile in only activates 80% of the time... 1 Answer