I need some help in creating a destructible cube. I already experimented a little but I just can’t get the needed effect. The cube has to be destructible, but it also has to have the ability to be placed anywhere in space and not to fall on its own. The player needs to shoot little chunks of this cube without causing the whole structure to crumble (right now it falls apart entirely when the first chunk is separated).
The second problem is that the character can destroy the cube while walking and colliding with it. The cube has to have the properties of a rock, so that player won’t destroy it while walking but he has to be able to collide with the chunks that fall off.
I assume that the “accumulate damage” flag should be checked and “support depth” in special hierarchy depths but when I set the value of the support depth to “1” the cube behaves strangely - I can destroy only one chunk and when I walk and collide with it, the cube bounces like a ball.
It would also be good to know if there is a way to set a different density (or size) of the chunks depending on the depth of the cube? Can the chunks of the outer layer be smaller than the ones inside for example? And is it possible to set a different texture to the “core” chunks?
Additional note: I added a radial force component to the projectile so it could cause destruction and a shape component for it to interact with the chunks.
Setting up this type of destructible isn’t too hard to get the most basic setup. It will take tweaking on your end to get the results you want for you for your game though.
For my setup I am using a line trace that applies a radial force on hit for my projectile.
Here is the setup I used to get the following results based off your description:
Goal:
Player cannot destroy asset by walking into or on the mesh
Object does not fall when the game starts or on its own
Chunks have to break off the mesh rather than destroyed all at once
Settings to adjust:
Damage Threshold: 500 (Set your damage threshold here, this can be tweaked. I set mine low enough that it would only take a hit or two to knock chunks off)
Support Depth: 1
Flags:
Accumulate Damage: (For my example it doesn’t have to be used but you can set that along with the Damage Cap to get a different result if you like)
Asset Defined Support: Checked
For additional control of your mesh select it in the viewport and adjust the following settings in the details panel:
Enable Hard Sleeping: Checked (This will keep other meshes that collide with it from waking it up and causing it to fall)
Physics:
Simulate Physics: checked
Start Awake: Unchecked (This will keep the mesh from starting active)
Angular Dampening and Linear Dampening: Adjusting these values can give you better results. It will take tweaking and seeing what works for your needs.
This should be enough to get you started with the basic setup.
If you need more control over your DM such as chunk sizes and different depths you will need to use PhysXLabs (the standalone application or the plugins for Max/Maya). With this you can assign different destruction depths and setup up smaller chunks to break away from larger ones.
There are also some good tutorials for using PhysXLabs to get specific results (They are a little outdated but the changes aren’t that significant that it cannot be figured out by looking around in the program). Tutorial are here.
For the “Core” texture you can apply a texture in UE4 that will be applied to the inside faces of the destruction.
Thanks for the help but I still can’t get the right effect. I am new to Unreal Engine and probably I triggered some stuff that I shouldn’t. Could you specify all the properties that the cube must have to behave? And What is a line trace that you use?
I am attaching some images of my setup for you
The line trace is in the MyCharacter BP. The other projectile is still there but just disconnected.
**Here is a tutorial I made quite a while ago for using the standard FPS template projectile with Destructibles. Step 10 is where the settings for that start. It’s a little rough around the edges since it was a rough draft. I’ll update at some point with this line trace version.
**](Dropbox - Error - Simplify your life)
Once you open the project provided above you’ll really only need to adjust the DM damage cap and adjust some of the settings for the DM in the details panel for the angular/linear dampening to help out.
So if my game includes thousands of such destructible cubes will the engine adapt somehow to the less powerful computer configurations? Is there any danger of burning the CPU straight to hell or BSODs and crashes?
Destructibles work but they require tweaking to get the results you need. You have to remember that the engine has only been publicly available for right around 7 1/2 months now. It’s still being developed and there are areas that need improving. Comparing UE4 to UE3 is a little unfair since it was released over 10 years ago.
In the last 7 months there have been vast improvements in the engine as a whole and with Destructible Meshes. I can confirm that the support chunks that you have asked about before is working in 4.6.
, unfortunately I can’t see the settings of your projectile. Is it possible to configure the standart projectile so that it damages the cube the same way? I’ve been tying a lot, but couldn’t make it.
@ : I tested this on a build that’s from 10/31 (CL: 2346079). That build is a few thousand changelist’s beyond where I’m at. That should work, but that is the bleeding edge build which can be volatile at times. But if you’re just wanting to test it out that one will work. I would recommend waiting for the 4.6 preview or full release before developing though.
It may be possible but will require some tweaks. I’ve not set anything like this up in a while to be honest. I’ve been using the line trace to get my hits since I stopped using the projectile ball. The way these two are getting the hit is different this is where the tweaking will come in. In the projectile ball version it is generating an overlap event when the capsule hits the destructible. Since the capsule is fairly large it is giving a large hit along with the force and velocity from the projectile itself. In the line trace version I’m casting a line out and applying a radial damage at the location of the hit.
Thanks .
Wanted to ask you though, how will the engine behave when the scene is filled with thousands of destructible cubes? Is there any danger of harming the CPU? This is very important for me.
I’ve not really gone super crazy with the number of destructible meshes I’ve tested in a scene…until now.
I used the test scene I attached above. I took the cube dm and copied it 576 times. Lined them up kind of like an alley way upwards on both sides.
I increased the cell count for the fracture to 200 for the meshes. My FPS stayed around 17 when all sorts of craziness was going on. I had all the meshes start awake as well.
All in all it wasn’t as sluggish as I thought it would be.
There are ways to improve this as well by setting timeout for the chunks so they don’t hang around forever and by using cull distance to make sure they are not all visible at once. These types of optimizations can help keep FPS up.
I don’t think it’s a problem having lots of destruction in your game, but the way it’s handled and how long it hangs around is key to getting good results.
So, no there is no danger to your CPU. You FPS can get really sluggish depending on the number of calculations that are having to be done with a single DM and it’s cell count though.