hi, im making a project and you need to throw a ball with swipe but my code have a touch phase so when i click in pause menu my code detects like im touching the ball and the ball drops, i have another code and i make a ball click area with a collider so you need to touch in the collider to shoot i want make the same but with this code, i tried with the same forms with collider but doesnt work.
if ( Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
{
// getting touch position and marking time when you touch the screen
touchTimeStart = Time.time;
startPos = Input.GetTouch(0).position;
}
// if you release your finger
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Ended && throwAllowed)
{
// marking time when you release it
touchTimeFinish = Time.time;
// calculate swipe time interval
timeInterval = touchTimeFinish - touchTimeStart;
// getting release finger position
endPos = Input.GetTouch(0).position;
// calculating swipe direction
direction = startPos - endPos;
// add force to ball rigidbody depending on swipe time and direction
rb.isKinematic = false;
rb.AddForce(-direction / timeInterval * throwForse);
// one attempt to throw a ball only
throwAllowed = false;
}