how do i create a collision that disables after the player jumps off of it?,How to disable a collider after the player jumps off it?

in my game, the player needs to jump from tree branch to tree branch (going down vertically) so i need to put a collider on these tree branches that disables after the player has jumped off of it. otherwise the player will bang their head on the previous tree branches.

i thought about doing a groundcheck type of thing where the collider becomes inactive simply after jumping, but i dont want the collider to disable if the player just jumps up and down on the same branch. so maybe the previous branch collider disables after the player collides with the another branch? im very new to unity so im not quite sure how to do this

thx

you could do something like this:
attach this script to your character, and make all of your branches have the tag ‘Branch’.

     public GameObject[] Branches = new GameObject[10];
     //this is an array for you branches, I only had like 5 branches so i put 10 as the max. if you want more branches you can make the number higher
 
     void OnCollisionEnter2D(Collision2D collision)
     //I will be using collision as the variable for what I hit, but you can use whatever
     {
         if(collision.gameObject.tag == "Branch")
         //Tag your branches with "Branch"
         {
             int i = 1;
             //variable for counting up, just like in for loops
             //I set it to 1 because otherwise later on it will give an error on line 30 about Branches[i-1] being outside the array index, because you cannot have Branches[-1]
 
             foreach(var GameObject in Branches)
             //this runs the loop for every branch possible(10 because thats what the max we set is)
             {
                 if(Branches*==collision.gameObject)*

{
break;
}
//this will check if you have already touched this branch, and if so it breaks
else if(Branches*==null)*
{
Branches = collision.gameObject;
if(Branches[i-1]!=null)
{
Branches[i-1].GetComponent().enabled = false;
}
break;
}
//This will find the first empty spot on the ‘Branches’ array, and set it to the branch you just hit, then turn off the collider for the previous branch, and then it breaks

i++;
//if ‘Branches*’ isnt what you just jumped on, or a blank space, it makes i be one more*

}
}
}
so just paste this into a blank script and hopefully it works! if you have questions feel free to ask and I will follow this question so that I cant find it easy to check if you had any.