I want to write a script in c# for a 2d object, in which I need to move object direction and speed as finger swipe on screen. I achieved to move object's speed as finger's speed swipe on screen, but now I want to move object direction (specifically Arc position like in paper through game paper move on same direction as finger swipe). I already searched on google but couldn't find help. Kindly share with me tutorial or any link or code any one who done this earlier. Thanks in advance.
1 Answers
-1
votes
you can find the direction by: saving a touch position in a variable(startVector) in 'Touch.Began' phase and then do the same in 'Touch.Ended' phase and save it in a different variable(EndVector). Now you have two vectors (StartVector, EndVector). Now, you can find the direction by: comparing the StartVector 'Y' or 'X' with EndVector 'Y' or 'X' e.g
if(startVector.y > EndVector.y){
//moved left
}else{
//moved right
}