Cutting down trees - setup help

Here’s my little test tree cutting game:

  • Pick up Axe - axeOwned = true;
  • Pick up Saw - axeOwned = true;
  • Then some weapon switch code to select saw or axe.
  • Tree code
  • grown = true;
  • OnMouseEnter - IF weaponHeld == axe, apply “outline highlight” shader
  • OnMouseDown - IF weaponHeld == axe, cut down tree, woodAmount++ (static variable), grown = false, Destroy
  • Saw Bench code
  • OnMouseEnter - IF weaponHeld == saw woodAmount > 4, apply “outline highlight” shader
  • OnMouseDown - IF weaponHeld == saw woodAmount > 4, plankAmount++

Is this a decent way to do this?

One issue I’m having is the tree. Right now it’s a parent cylinder for the trunk, with child spheres as the leaves. This script is only attached to the parent trunk, so only that highlights OnMouseOver. I want the entire tree to highlight OnMouseOver. I could import a single tree model, but I don’t want to right now.

Also, what’s the best way to display a “stump” after the tree is cut?

The tree should also needs to grow back after a while, so should I “hide” it instead of using “Destroy”?

Download - Here is the GameMaker version I made - no install required. Click the axe/saw, and then 1/2 switches between them.

Does it give the wrong visual effect if you apply the outline shader to the leaves individually?

As for the stump, you could keep a separate child object on the tree and hide it by setting its renderer.enabled property to false. When you need to display the stump, hide the main tree mesh and show the stump. Then, switch back when you need the tree back again.