# Touch sides of tablet, moves that direction

| | August 8, 2015

I am making a game where the player flies a balloon through a cavelike structure.

I am having trouble making him fly correctly when I try it out on my android tablet, seeing as it requires different input to move.

How can I make the player move towards the touched side? By creating a ray? through touched objects? :)

## 2 Responses to “Touch sides of tablet, moves that direction”

1. Following along with the other suggestions, you can use the screen width to determine the left or right side of the screen. I might also suggest using a dead spot around the balloon. Precision touching can be difficult. if you split the screen on a single column of pixels, touches near this divide might get registered on the wrong side of the line that the player wants.

This bit of pseudo code assumes that the balloon stays in the center of the screen and the background moves.

``````var leftBounds  : float = screenWidth/2 - balloonWidth/2;
var rightBounds  : float = screenWidth/2 + balloonWidth/2;
if (Input.touchCount > 0) {
var touchPositionX : float = Input.getTouch(0).position.x;
if (touchPositionX <= leftBounds) {
}
if (touchPositionX >= rightBounds) {
}
}
``````

If the balloon does not stay in the center of the screen, then the `leftBounds` and `rightBounds` will have to be calculated off of the balloons current position.

2. Using two different inputs (one finger and two fingers) for a same action (add a force) can be disturbing.

I would suggest you to only use one finger and orient the force accordingly to the touch position on screen.

As you seem to use Unity, you can easily get the touch position thanks to Input.mousePosition. Combined with Screen.width you will know if player has touched left or right side of the screen.

I don’t know much about the actual gameplay of your game but with such technique it’s easy to determine the actual force applied accordingly to the finger position… you could says something like “the closest of the border your tap is the biggest the applied force is”

I hope it helps.

• ### How To Submit a iPhone App to the Appstore

by on July 5, 2012 - 0 Comments

The process to develop an iPhone app is not as hard as one might think. The entry into the app store has been opened up to many new types of develope...

• ### Develop iphone Apps on Windows

by on March 7, 2011 - 13 Comments

Top 10 Ways to Develop an iphone/ipad app without a Mac #1. Code in Java For Java developers, there is a workaround: XMLVM. XMLVM cross-compiles byte...

• ### Iphone Android App Ideas: Getting Started

by on March 19, 2011 - 3 Comments

Smartphone Application Ideas: Getting Started Smartphone application developers are constantly on the move. And since overzealous developers stick ...