I am trying to get wood to spawn near the tree every time i hit the tree with my axe but I don't want to destroy the game object please help

please help

I’m not sure how you have your code set up, but as long as you are not calling Destroy() on collision and call Instantiate(wood_prefab) instead then that should achieve your desired outcome.

public int max_num_hits = 5;      //this determines the number of hits until a tree is destroyed
private int current_num_hits;      //this counts the number of hits a tree has taken

public Start(){
//On start we reset the number of current hits
current_num_hits = 0
}

OnCollisionEnter(Collision collision){
   current_num_hits++;      //increment our number of hits
   if(current_num_hits == max_num_hits)      //compare current num to the set max
   {
      Instantiate(wood_prefab); 
   }else{
      Destroy(this.gameObject);
   }
}

}

Attach this strip to your tree. Assuming your axe and tree have the proper colliders, it should work.

You’re going to want to make a wood object prefab and instantiate a new one every time you hit your tree with an axe.