I would like to make a little 2D mobile game (Android) , when you swipe anywhere on the screen, the character should move in that direction. Not only left, right, up and down, but any direction.
I´m new to Unity and it would be awesome if someone could help me
THX.
im not the best, but about what tou need to do is use Input.GetTouch(0).deltaposition to get your values, then setup if statements to check like (and this is probably the worst way because im new)
if(input.gettouch(0).deltaposition.x > 0){
debug.log("user is swiping to the right");
}
if(input.gettouch(0).deltaposition.x < 0){
debug.log("user is swiping to the left"):
}
if(input.gettouch(0).deltaposition.y < 0){
debug.log("user is swiping to down"):
}
if(input.gettouch(0).deltaposition.y >0){
debug.log("user is swiping to up"):
}
put all that in update.
So “Input.GetTouch” gets touches from the input manager Unity makes, then (0) signifies to use the first touch. “deltaposition” is the change in position from last frame (if i remember correctly). You just uise that data to determine how the touch is moving, which is of course a swiping motion if touch(0) has its value changed.
currently im using that for rotating a cannon up and down using