use collider from ontriggerenter in another function

Hi im trying to use the collider found in ontriggerenter inside of another function is their a way to do this

Perhaps call the function from inside the OnTrigger function passing the Collider.

Or you could store a version of it in a variable declared outside of the function, from inside the function.

I’m not quite sure how your two snippets are meant to relate but, yes, there’s no reason why you can’t store the “car” object with which you’ve collided in a local variable somewhere and then access that from another function.

Collider theCar;

void OnTriggerStay(Collider car) //while we are in the collider
{
  if(car.tag == "car")//checking if it is a car we are standing near
  {
      theCar = car;
  }
}

void DoSomethingWithTheLastCarWithWhichWeCollided()
{
  // Do something with theCar
}