ApexAsset for DestructibleMesh not loading on cooked game, but does on play in editor

After migrating to UE 4.18 all destructible meshes in our game stopped working, except when running the game on PIE.

Debugging a little bit, I found at the moment of deserializing in UDestructibleMesh::Serialize the deserialized ApexAsset is NULL if running as cooked standalone game, but deserializes correctly if running from editor.

The cooking process didn’t give me any warning regarding destructible meshes. Any idea what I should be looking into?

UPDATE:

Debugging further I’ve found the NvParameterized serializer didn’t have the factory for “DestructibleAssetParameters” version 26 registered at the time of loading the destructible mesh assets.

Seems like the reason our destructible meshes are working fine when running from Editor is because Apex Destruction is properly initialized before the game assets are loaded, however, when running standalone (a configuration without editor) the game assets are loaded before FApexDestructionModule::StartupModule is called.

Is there a way I can force the module to load first?

I’m still getting this behavior in 4.18.2. Did you ever figure out a workaround?

My work around was to load the DestructionModule when Apex is first initialized, instead of doing it in the plugin StartupModule (basically restoring what it was doing before 4.18).

I think other possible solution would be to not have any startup asset reference destructible assets (no direct or indirect references through base classes, singleton, etc), so that any destructible asset is loaded after all plugins have been initialized.

How could you go about this? Been struggling on this for around a week!

I’ve been working through this over here: Destructible mesh loses collision and physics after packaging in 4.18.2 - World Creation - Unreal Engine Forums

There’s a bug ticket now, Unreal Engine Issues and Bug Tracker (UE-54133)

Same here, would love to know more about where apex is initialized.

Been trying to somehow spawn my destructible actor from my character class without actually referencing it… No luck so far

Thank you so much for the reply! Really need this as its for a uni project thats in soon! Where abouts is the PhysXLibs.cpp in the engine folder?

Basically added back LoadPhysicsLibrary for APEX_Destructible in PhysXLibs.cpp (right after Legacy and Clothing are loaded) instead of loading it in the plugin.

Engine\Source\Runtime\Engine\Private\PhysicsEngine

Thanks so much for this I really apreciate it! Ill try it when i get home and report back if it fixed the issue for me! But really thanks soo soo much. Theres so little info on apex destruction in c++.

Is loading the libary all i need to do? Or do i need to add the lib back or anything?

Thanks again!
Joe

Look at what it does with the others and try to replicate it, you may need to modify headers too. You can also look for old revisions of the source code to compare.

So ive tried it and its stil not working, the apexdestructiveasset is still null, what headers would i need to change? Thanks again

Did you get it working @JMigCarrier? Theres so many files that the engine has in 4.17 and not in 4.18 in regards to destructiblemesh etc…

Yes, I got it working, it’s not too difficult, but is not a single line change either.
As I was telling you the key is loading the destructible module on PhysXLibs.cpp, you will need to add back an apex::ModuleDestructible* GApexModuleDestructible pointer on PhysicsPublic.h, make ApexDestructionModule.cpp use that instead of loading it inside the plugin, and instantiate the module on PhysLevel.cpp (just like it does with Clothing or Legacy). The other Apex modules can work as example, replicate what they do or use the old source code as example.

Did you put the plugin in the project directory? or keep it in unreals dir?

It’s on Unreal dir, didn’t move it.

Alright thanks, Ill keep trying. How do I make the ApexModule use the engine init and not the plugin one?

And are the files you listed the only ones that need editing?
Sorry for all the questions its just for an assignment lol and im not that great at c++

@JMigCarrier This requires a full engine rebuild, correct? That may be a huge issue for me since the class library I use for my mod toolkit will need to work on vanilla 4.18

Correct, my workaround was to modify the engine.

I really needed the engine to behave like it did before 4.18 for a commercial project, so I modified it. But a simpler solution would be to not have any destructible mesh referenced by any of initial assets that the game loads (for instance, only have those referenced by actors placed in the level), in that way the destructible plugin would have been already initialized when we time comes to load those destructible meshes.