Download

Trees that you can chop down

Hello i am making an open world game but iv bumped into a problem i have no idea how to create a tree that you can cut and it gives you logs.

After the tree has been cut it gets destroyed and a few minutes later a new one appears how would i go around creating this?

Create a class Tree. Give it a mesh, and few variables:

  • maxChops
  • logsToGive

Make a function OnHit() override and track how many times the tree has been chopped. if it has been chopped as much as maxChops call a new function DropLogsAndDestroy() where you will spawn few logs or directly give them to the player inventory.

As for the respawning, you can run a timer on Destroy() for 90 seconds (or as much as you want) and show it again refreshed and ready to be chopped again.

Thanks man!