hi there is a slight problem in this code swipe is working with out releasing my finger but it is working more then once when i swipe my finger and stop with out releasing and swipe again with out releasing my finger then action is repeating twice can any one fix this problem action should be once per swipe with out releasing my finger here is the following code that i used
if(Input.touches.Length > 0)
{
Touch t = Input.GetTouch(0);
if(t.phase == TouchPhase.Began)
{
//save began touch 2d point
firstPressPos = new Vector2(t.position.x,t.position.y);
}
if(t.phase == TouchPhase.Moved)
{
//save ended touch 2d point
secondPressPos = new Vector2(t.position.x,t.position.y);
//create vector from the two points
currentSwipe = new Vector3(secondPressPos.x - firstPressPos.x, secondPressPos.y - firstPressPos.y);
//normalize the 2d vector
currentSwipe.Normalize();
//swipe upwards
if(currentSwipe.y > 0 && currentSwipe.x > -0.8f && currentSwipe.x < 0.8f)
{
lastJumpButtonTime = Time.time;
}
}
}
if i use TouchPhase.Ended then swipe will function after i released touch i want swipe to be function with out releasing touch only once eg...[link text][1] like this game [1]: https://play.google.com/store/apps/details?id=com.gameloft.android.ANMP.GloftJDHM&hl=en
– santosh810666if u want to use swipe in move phase, then use touch.deltaposition to move the object on swipe.
– hirenkachathanks for your reply i am new to the touch can you please explain me how to use touch.deltaposition
– santosh810666