Help with touchscreen controls

Hi everybody! I’m new to Unity and to scripting… I’m trying to make a small game for android but I’m having some trouble with the touchscreen movement, it works fine with the keyboard on the PC. I only need to move my player left and right. I have tried lots of scripts found on the Internet but none seemed to work… My original idea was to divide the screen in half and make each half a button. Another way I think is to make two buttons for right and left, I have tried but I can’t understand how to do it. I use C# but Javascript is fine as well. If you could show me how you’d do it, it will be very much appreciated. Thanks in advance.
P.S.: I know how to move the player, I just don’t know how to use touchscreen input.

if (Input.touchCount == 1)
{
Touch touch = Input.touches[0];
if (touch.position.x < Screen.width/2)
// Something that does what you need if left side is touched
else if (touch.position.x > Screen.width/2)
// Something that does what you need if rightside is touched
}

try TouchScript, its free and worked great for me after around 30 hours of fiddling around to learn how it works.

u could totally create an invisible plane for the left side of the screen and one for the right side. u can attach a press gesture to each plane and have the callback move the character left or right depending on which plane was pressed. What’s nice is that you can also test this with mouse because touchscript has a built in emulator for it.

Alternatively you can have a full screen layer for the camera and a press gesture on it. Whenever any press is detected simply mathematically check whether its to the left or to the right of the midpoint of the screen, and then move the character accordingly.

I like second solution better since you don’t have to make any extra objects.