I have a quick question. I’m working on a tree system similar to the one in Lumber Tycoon 2 (Roblox), where the player can cut the tree at any segment. I’ve created multiple segments of the tree (all static meshes) and implemented logic to destroy the cut parts and enable physics for the remaining segments. You can check out the video to see my current code: [Help Video - Made with Clipchamp].
I have two questions:
Is there a more efficient way to do this?
I feel like I’m writing a lot of code just to make one segment detach from the tree (it reminds me of how World of Warcraft developers used a lot of if statements, but worse!). Is there a better method to handle this?
How can I group the segments together so that when I cut a segment (e.g., part 1 or part 3), the remaining segments above group together and fall like a tree?
I want the segments to behave as a single object once physics are enabled, no matter where the tree is cut.
If I’m approaching this incorrectly, any advice or alternative methods would be greatly appreciated. I’m just trying to replicate the tree system from Lumber Tycoon 2 as simply as possible.
Thank you!
(edited because link did not work, I cant post video without link because I’m still new. )
In my case I am converting the ‘tree’ to be cut into a Dynamic Mesh, and I have another dynamic mesh which is a saw blade and use a boolean ‘subtract’. I can make partial cuts or cut through a tree. After a cut I check ’ Get Num Connected Components’ to see if I have 2 or more objects. If it is 2 or more, I create seperate DynamicMeshActors for each component, turn physics on and voila the tree branch/trunk/etc falls realistically.
I have converted my code to C++ because the Blueprint started getting pretty complicated. I am still working on getting the feel correct for objects that have been rotated before being cut. It has been a fun little project.
Also if I make additional cuts to a Dynamic Mesh Actor, no need to convert from Static Mesh to Dynamic Mesh. Also need to manage a Dynamic Mesh Pool (which defaults to 1000 items before it complains and causes garbage collection.)