Roblox lumber tycoon trees

Godot Version

4.7 3d

Question

I’m making a game inspired by lumber tycoon with ps2 graphislcs however I’m having an issue making trees that can be chopped anywhere and into multiple pieces with the shape of the logs being identical to what youve cut. Right now I’m just looking for how I should go about this, I’m not asking for a long line of code just a general direction I should go.

I’ve thought about how gmod had it so when a ragdoll loses its limb its still attached to the character but invisible and their limb is duplicated as its own thing to make it look like they were dismembered. Of course for tree logs that can continued to be cut this would mean a lot of invisible trees and that probably wouldn’t be great for performance.

I’ve seen far more complex methods but I don’t want to start doing highly complex code just for it to not work in the end. That’s why I’m asking for a general idea of what I should go for to make this work the way I want it to

I need a lot of trees in the area, I want woods with open areas so there will be a lot of trees. For trees off in the distance I could use a lower quality mesh but when coming up close they still need to be there and interactable. I know this is a different topic just wanted it to be kept in mind so when I get to that I can still get my desired outcome

The trees will have a decent amount of variations to them so modeling every tree and every possible cut would be a monumental task

The cut trees will need to be movable and have different weight values depending on the size of them, something that came to mind with the invisible tree aproach

The trees do need a way to respawn on a terrain3d built world. This could either be points under the map that allows trees to spawn but with a big map this could be pretty difficult and also a performance issue. The people behind terrain 3d showed off a tool that would be great for spreading stress around a map but it looked weird and I’m unsure if they would still have the same capabilitys

I might be asking a lot but most of this I can figure out myself but I don’t know what approach I should start with so that I don’t waste time on it just to have to make something else anyways.

This is my first game I’m working on so my knowledge on the engine and what I look up to figure out more about it is limited since I don’t fully understand everything yet


Trees in Lumber Tycoon look like just a hierarchy of parented boxes, and chopping is just unparenting the branches of that hierarchy.

If I recall lumber tycoon correctly, you have trees, you chop them, they fall apart, the player then carries the logs back to their factory, before selling them.

I recommend prototyping this in the most basic way, before trying to refine it (e.g. by adding lots of tree types with realistic breakage points, realistic looking trees, or making it work on Terrain3D). Otherwise you risk making things too complicated at the beginning. It is also a good chance to prototype the gameplay by distilling it down to the essentials.

Similarly, if you haven’t already, start with simpler projects. This requires you to understand the basics of scripting (signals, variables, functions, classes, node traversal), scene creation, player interaction, 3d physics (areas, rigid bodies, joints - all quite easy).

The way I would make a tree spawning pool is:

  1. place points in the world where you would like the trees to spawn
  2. add the points to a collection
  3. have a ‘tree spawn manager’ script that both spawns the trees at the locations of these points, as well as keeping track of which points are occupied
  4. when a tree is chopped down, notify the ‘tree manager’ that a point is free
  5. ‘tree spawn manager’ sets a timer before instancing a new tree scene

For the tree, I would:

  1. create a scene with a basic Minecraft-like tree that is already split up into the parts it will break up into (e.g. 3 bits for the trunk, 2 bits for the canopy) - like normalized suggested. each part should be a rigid body held to each other with a joint.
  2. name the trunk, leaves etc. respectively (or use metadata)
  3. create a ‘tree’ script that will be responsible for randomising the rigid body weights and deleting the joints
  4. on ready, the script would iterate through all child rigid bodies, and set a random weight. this can be based on the name of the node or its metadata
  5. on chopped, the script finds all child joints and deletes them, and signals the ‘tree spawn manager’ that that point is now free

From there, you would need to add movement of the logs, and dropping them off. Movement of the logs would likely involve attaching a spring/joint to the hit point of the log and a fixed location in space when left mouse is held. The location of the fixed location changes depending on the player location/position (e.g. it is 2 units in front of the player if in 3rd person view). The drop off location would be an Area3D that would check for logs present. When a button is pressed, it would delete the logs in the area (and presumably deposit currency).

I wouldn’t be too concerned about the performance of having too many trees as of yet, as the bodies go to ‘sleep’ when they are inactive. If you really have that many trees, you can make them static bodies by default, and when the player starts chopping (or comes close) set the trees to regular bodies.

I am unfamiliar with Terrain3D specifically. The way the tree rendering appears to work is via instancing or batching. Basically, one model is fed to the GPU and it then draws the same thing at multiple points (which is likely why it needs to be a singular mesh). The fact you’re seeing multiple trees is more or less a mirage (so is all of 2D/3D rendering, but I digress). You would need to temporarily replace the instanced tree with an near-identical looking scene of the tree (with logic etc.) if the player is nearby (or starts chopping) - and delete it again and show the instanced tree (if not deleted). A tree spawn manager script would keep track which trees have been chopped, and that need to be placed. This would alleviate performance issues related to having too many trees.

If you’re going for a PS2 polygon-like look then I wouldn’t be too concerned about the rendering performance on modern hardware (unless you use some oversized textures or overly tessellated meshes). Textured polygons are cheap to render.

After you get this working, getting the trees to break into more ‘realistic’ chunks would be a case of bisecting the mesh and colliders. In Unreal, you would use the Chaos Fracture plug-in. I am not sure something like this exists in Godot, but it would be based on bisecting a mesh along a plane (involves quite a bit of maths, including understanding of quadratics, plane-polygon intersection, and matrices). I don’t think this is essential for your game, however.