First destructible mesh in level disappearing without fracturing

I have a level containing around 500 destructible cubes. Whenever I load it, first couple of cubes don’t fracture when damage is applied to them, just disappear without creating any chunks. After destroying ~10 of them everything works correctly (chunks are created).

Chunk count for each cube is 40. The usual Apex max chunk count shouldn’t matter in this situation, because there are no active chunks in the scene.

Okay, got it working. Even after changing the engine’s ConsoleVariables.ini file the packaged game would not keep the settings.

What I did is add PhysX/APEX modules to dependencies (in Build.cs):

PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "PhysX", "APEX" });

Then include the PhysXIncludes and PhysicsPublic file:

#include "PhysXIncludes.h"
#include "PhysicsPublic.h"

And finally override the max chunk count property of ApexModuleDestructible:

GApexModuleDestructible->setMaxChunkCount((physx::PxU32) MyDestructiblesCount);

This works, but I am not sure if it’s not a very ‘hacky’ way of approaching this.
I will mark this as an answer and the question can probably be closed.

Nevermind, it was related to p.APEXMaxDestructibleDynamicChunkCount after all, but it only worked after I changed it in the general engine config file. Looking for a way to change it for single project only now.

Did you get this figured out or did you continue using what you made above?

I did add these lines to the Console ini file and also the engine ini file and they work int he editor but when I package the game for the console they do not work. I was trying to limit from the default 2000 to 500 for performance reasons on the console. Do you have any idea why this would not work on the console?

p.APEXMaxDestructibleDynamicChunkIslandCount=2000 p.APEXMaxDestructibleDynamicChunkCount=10000

I don’t know how you figured this out! I am struggling to get this to work, I cannot find ApexModuleDestructible, there is a ModuleDestructible but it has a [pure virtual] variable, when I put a number in there it fails to compile. Do you know where you would put the following inside the ModuleDestructible?

GApexModuleDestructible->setMaxChunkCount((physx::PxU32) MyDestructiblesCount);

Want to thank you sg_badyl, you were very smart to figure this one out, there is no information anywhere.

Finally got it working by following your instructions, only things I did different were the following, hope this helps someone in the future but probably wont sing Epic is making their own destructible tool.

  1. This file ApexModuleDestructible is actually named ApexDestructibleModule

  2. Change the following in the ApexDestructionModule.cpp file, the default was 2000 and I changed both to 1000, may event change to 500 will need to do a little more testing.:

static TAutoConsoleVariable CVarAPEXMaxDestructibleDynamicChunkIslandCount(
TEXT(“p.APEXMaxDestructibleDynamicChunkIslandCount”),
1000,
TEXT(“APEX Max Destructilbe Dynamic Chunk Island Count.”),
ECVF_Default);

static TAutoConsoleVariable CVarAPEXMaxDestructibleDynamicChunkCount(
TEXT(“p.APEXMaxDestructibleDynamicChunkCount”),
1000,
TEXT(“APEX Max Destructible dynamic Chunk Count.”),
ECVF_Default);