Answer the question
In order to leave comments, you need to log in
How can I implement the movement of cubes with a swipe?
Hello everyone, I decided to remake the game from the tutorial and remake it for Android. I've tried a lot of methods, none of them worked. It is necessary that the pink and blue cube move along the x-axis (shown by arrows in the screenshot), and the green cube (it is hard to see that it is green, but the material on it is green :/ ), move up or down along the Y-axis.
That is, swipe across the screen to the right or to the left and the pink and blue cube moved in the direction of the swipe, and if you swipe up or down the green cube moved in the direction of the swipe
Answer the question
In order to leave comments, you need to log in
Swipe, what is it in fact? is the distance between the start point of touch and the end point.
We can also find out the direction of the swipe, you went through this in algebra lessons. Cartesian coordinates. x and y.
If the end point in Y has become smaller than the previous one, then move down. At the same time, it is necessary to give some kind of “blind zone” for swipes, or whatever it is called ... in general, it will be difficult for the player to move the finger along Y without moving along X. Therefore, one must abstract oneself from the results, where the shift along X is almost didn't change.
Excuse me for not giving you the code, I am writing from the phone, the computer is 30 km away.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question