How can I check if a certain Touch exists?

I can’t find a way to check if a certain touch exist script below
"foreach (Touch touch in Input.touches)
{

                if (some requierments)
                {
                    follow = true;
                    followTouch = touch;
                }
             }"

so my code just make an object follow my touch(I have stored the Touch in a variable ‘touch’)
and once the touch doesn’t exists anymore I want it to go back to his native position(this is the parent’s position ‘transform.parent.transform.position’)
Things I have tried
1)

if (Input.touchCount < 1)
{
//doesn't work because you often have multiple touches
}
if (touch != null)

// but i can't compare a touch value and 'null'

there neither is a touch.exist to use

Questions so what’s a way to check if a touch is ‘alive’ or is there maybe a way to find the index of a touch (while the touch is stored in a variable)

Not really sure if I understand your question, but instead of saving the touch; save the index!
So then you can do things like,

if(Input.touchCount > followTouch){
//Do stuff here with Input.GetTouch(followTouch)
}
else{
//The finger is let go.
follow = false;
followTouch = -1;
}

So followTouch is now an int :slight_smile:

Hope this gets you further!

-Gameplay4all

EDIT:

So you have this piece of code:

foreach (Touch touch in Input.touches) {
  if (some requierments)
  {
    follow = true;
    followTouch = touch;
  }
}

Change it to:

for (int i = 0; i < Input.touchCount; i++) {
  if (some requierments with Input.GetTouch(i) )
  {
    followTouch = i;
  }
}

Now you can use the code I mentioned in my original answer :slight_smile:

And where you have followTouch declared, change it to an int.

Going to answer my own question here just use this
if (‘TouchVariable’.phase == TouchPhase.Ended)
{ }