Cutting trees

Hi, does anyone know a way to cut down a tree so that the axe makes a hole (axe mark) in the tree trunk like a boolean, and when it is completely cut down it falls. My idea was to use a dynamic mesh component and geometry scripning and use apply mesh boolean to cut the tree, but when the tree is cut it just floats in the air and I haven’t found a way to turn on physics for dynamic mesh.

I know many people are using materials or chaos physics but that isnt that look i want. I want so that axe makes that hole so its more realistics.

Does anyone have any ideas thanks

by hole i mean this cut in tree that the axe make:

I think the tree must be made in two pieces previusly.
Then you can modify rotation an location (with a time line) to simulate the drop.

But… do you want a forest?
Because geometry scripning drop the performance a lot…
Try 100 or 200 trees and you will see the FPS drop will be important.
1000 trees will be crazy…

I would use geometry scripning only to save static meshes

Typically you remove the foliage HISM and spawn the new pieces at the same location. For multiplayer its a bit more complicated.

I’d personally make the chops material based. Use a DMI to update the material instance.

So On initial interaction (first chop) spawn the replacement actor, then remove the instance.
Apply the DMI effects to the new actor. Once enough dmg has been applied enable physics on the top aspect, then disable physics on rest. Bump dampening to speed up the rest.

1 Like

@Ivan3z @Rev0verDrive I was more likely asking how I could use the axe to cut out the triangle that would match the shape of the axe, because using geometry script I was unable to add physics or detect whether the tree was completely cut in half.

You can try this tool

UGeometryScriptLibrary_MeshBooleanFunctions::ApplyMeshPlaneCut(...);

Exactly…

I think is better do the same as the video privided by @Rev0verDrive

UGeometryScriptLibrary has a very bad performance

And another way to make this boolean does exist? witch will ve able to add physics

You can try modular Meshes.
if it can be done with a character, with a tree will be easyer

1 Like

Requires a skeletal mesh, then for physics a phys asset.
Will be hella expensive.

2 Likes

Our friend has few options left… The same thing happened to me… I wanted to do a lot of cool stuff, and I’m still figuring out how to optimize a bunch of things. Unreal’s Achilles’ heel is using a single core for the game thread… a nightmare. It would be great if it used multiple cores… we’d make some incredible games.

It’s an interesting thread, but I’m not following this. If the chops are material based, do you mean that the cut created on the tree trunk is (similar to) a position offset created in the material itself? Then what about showing the insides of the tree?

I’d probably make a tree model out of parts (all the parts that can be chopped puzzled together). Then on the tree actor, when the tree is hit I’d measure which mesh part should be removed. Then when X parts are removed, “drop the tree” using a single bone on a skeletal mesh.

If the tree is going to be replaced, shouldn’t it be inexpensive to have only the replacing actor spawn using a skeletal mesh?

I’m thinking of that game “The Forest”. You can chop trees and at some points (say, you just detect X amount of hits) half the tree falls, in the direction the character is facing. When the tree hits the ground, Y amount of logs are spawned. Seems to me like a skeletal mesh is the way to go for a single tree instead of a physics based (static mesh) solution which can glitch more easily?

True the GT only runs on a single thread, but you can ease its load with async and worker threads. You have to do all the leg work and manage it though.

https://inoland.net/unreal-engine-5-multithreading

1 Like

Yes, I know… but since you can’t manage actors references from other threads different to the game thread, it’s very complicated… I practically don’t have anything that I can manage in other threads.

Yes, 100% material based. I’ve seen these things done. Material designers are wizards. I’m a game play mechanics and netcode guy.

Skeletal meshes are heavy. Especially if you want Physics. You’ll need a physics asset class for the ragdoll. Imagine 100 trees chopped, partially chopped in a scene.

Chopped tree actor is 2 “static” meshes. The Stump and the chopped off part.

As soon as the first chop is made you need to have the new actor spawned, Chop counted and its damage applied… And the HISM foliage instance removed. The chops (int) needs to be a Repnotify and the actor itself needs a sizeable netcull distance.

Say you have 50 trees in the area that have been chopped down. When a player walks into that area for the first time you want all the previous chopped down trees to be spawned and felled. BUT you do not want this player to see them fall. These are old actions to game play, but new to them.

The onrep function will handle the felling based on the number of chops applied. The netcull distance ensures they fall well before they can be seen falling. Unless they are in the NCD at the time of the final chop.

Glitching can happen to skeletal meshes too. Never seen a player get shot to the moon bumping into a static mesh or another player? It happens. Performance wise, especially on a potentially large scale the static mesh would be the better component.

2 Likes

I started writing a tutorial on using a material to simulate something similar.

atm this just affects all sides, but it could fairly easily be made to only carve out the hit side (and different angles based on the cuts in the mesh).

I was also going to animate the felling in the direction of the cut based on vertex rotations from the center there.

I don’t know if it would be any help to you, but here for prosperity:

2 Likes

Thanks for posting this. Pretty much exactly what I was inferring to. A more advanced approach would be using Substrate.

1 Like

true :smiley: I imagined it as “more stable” as you can create a joint between bottom and top part of the chopped tree but asides from having a joint that doesn’t necessarily mean stable physics. I thought the skeletal mesh would be used only while the tree is falling (to prevent a log from launching to the moon). A partially chopped tree would still be a static mesh, and a tree fallen down wouldn’t require a skeletal mesh if again replaced by a static mesh.

Technically… a non physics based “falling down” animation could be added on a static mesh as well, can’t tell how it compares in performance without testing. The direction the tree falls towards could then still be specified. Then (unless you get creative) you’d still have to figure out collisions (non flat landscape, other trees etc.).

The original question of the thread is how to make a realistic cut in the tree :slight_smile: but how it should fall or end up is not specified.

As I noted previously you don’t want 50+ SKM’s in a single scene at any given point.

End of day you need a handful of functionality and gameplay mechanics.

  • Any tree hit at least once needs to be replaced. Regardless if it’s ever fully chopped down.
  • It has to be performant regardless the number of trees partially chopped down. Somebody is gonna test it. Your gameplay intent means nothing on a released product. It will be abused.
  • If it needs multiplayer support then the network footprint per tree needs to be small.
  • The replacing actor needs to be self governing. It receives a simple update from the server (hits)

When all is said and done you can still have the new actor add a stump instance to the foliage HISM instance, then destroy itself… no netcode needed.

Interesting and fun thread!

So here is how would I do this system.

  1. Tree : A Static Mesh with dynamic material.
  2. Matching Cut Angles: On Hit animation, depending how you set the interaction cut angle be automatised or you get the hit results of axe to apply a mask on specific part of the mesh uv. Another way is to use a shader that you spawn a mesh over there that have a stencil . Stencil cuts would be an easy option there or cross section since we will need to fill it anyway
  3. OnCut: After a specific number is reached etc. Copy mesh to dynamic->Boolen slice cut with a specific angle->Copy Mesh back to static meshes->Lower is placed, upper is physics enabled with a force toward cut side.-> Upperside has a new parameter that dissolves tree, makes it go away (or some more crazy design over here to save the cut tree state and decay over days )

Here is some design problems to think about.

  • If trees can be cut from any angle and angle of interaction then determining the full cut can be problematic. Its recommended to have a certain hits from divided cardinal angles. If any section receives total of N cuts is considered done. N can be depending on tree age,size.
  • What to do if player cuts from a side a bit then goes other side and cuts a bit from there. Is tree cut or not.
  • Since we are making realism and realisation on this interaction; we will need some kind of animation during the cutting process on the tree. Rather than having skeletal meshes every where think it can be done by a simple shake scripts and some slight rotations to achive the weight of these impacts.
  • Since we are making realism and realisation on this interaction; we will need a very nice sound design (I particaulary like the sound design of NewWorld cutting trees)
2 Likes

I made this small concept without using anything custom stuff just with blueprints.

Demo3

  • Trees PCG Static meshes with a material function implemented.
  • A CutActor, that detect static mesh overlaps, controls overlapping trees material function. In background creates a dynamic mesh as filler copied to StaticMesh. Spawns some splinter vfx on vertices.
  • CutActor on cut creates in the background, top and bottom boolean meshes and ready them to be spawned on cut.
  • (Didn’t push futher) On cut command we can push step the cut object. After a treshold is reached (bounds volume or cut interaction number). Top and Bottom meshes are made visible and phsyics would be applied to top. A problem over here to access pcg spawn to be hidden or removed.
  • Sound of cracking, swoosh tree falls, physics disabled, player gets loot, tree is removed with material.

If a company pays me I do it :slight_smile: but can share material functions and raw protoscripts for cutter (which is ugly) however these whole concept can be done also just using dynamic meshes. It is possible to detect on cut angle have a collision and detect if cut is fully reached. Howerver in terms of fun maybe it is too much effort for player decreasing its fun, On the other hand there is an opportunity there in terms of item crafting/blacksmith to have bigger better axes lowering effort spend pushing player into getting stronger with craftsmiths.

3 Likes

How performant is this?

Consider an 8x8 km open world 64p multiplayer w/30-50k interactive actors. A few thousand trees easily. Any tree that’s chopped at least once has to be replicated to all other players.