Trying to have a GuiText stop counting when an object collides

Hello,
I don’t have a code to show, but I am trying to figure out a response:
I have a GUI text appear as a timer when SPACE is pressed. This launches a cube into the air that will fall and collide with the terrain. Once the collision occurs, I need the GUI counter to stop counting. Any ideas?
This is for an educational game; thanks in advance!

If you flip a bool to true once you hit space, then trip to false once it collides with something that might give you your result… something like:

private bool InAir=false;
private float timer=0;

void Update(){
  if(!InAir && Input.GetKeyUp(KeyCode.Space)){
    InAir=true;
    //PUT FORCE APPLICATION HERE.
  }
  if(InAir){
    timer += Time.deltaTime;
    //UPDATE GUI TEXT HERE...
  }
}

void OnCollisionEnter(){
  InAir=false;
  timer=0;
}

In the past, when doing things like this, I’ve had to use invoke to cause a delay in setting InAir to true, because sometimes it’ll take more than a single frame to become clear of any colliders, so as soon as you hit space it would then collide with something and thus then not be in the air anymore when it really is… Heres how THAT would look:

void Update(){
  if(!InAir && Input.GetKeyUp(KeyCode.Space)){
    **Invoke("SetInAir",.25f);**
    //PUT FORCE APPLICATION HERE.
  }
  if(InAir){
    timer += Time.deltaTime;
    //UPDATE GUI TEXT HERE...
  }
}

**void SetInAir(){
  InAir=true;
}**

void OnCollisionEnter(){
  InAir=false;
  timer=0;
}

Hope this helps in some way!

you might want to use FixedUpdate I think it was called. It’s a function that gets launched when a physics step happens, like velocity added or something else. Or if you want to be more specific you can use: OnCollisionEnter. This triggers if the object collided with something.