Download

Destructible Components

Hi again. Stucked with destructible meshes, maybe y can help me, guys… I have some actor, which i want to make destructible after death, it contains from UStaticMeshComponent’s, but for unknown reasons i can’t make it to be shown in viewport after creating destructibles.

In constructor i have this one asset declared for death sequence, didn’t want to create separate class (actually i had UStaticMesh, but casting from ustaticmesh to USkeletalMesh didn’t work for me, so i was forced to create a sphere with a bone for testings);


SklMesh = ConstructorHelpers::FObjectFinder<USkeletalMesh>(TEXT("SkeletalMesh'/Game/SomeContent/Models/sphere/sphere.sphere'")).Object;

//function

void ASomeActor:Destruct()
{
destruction = true;

for (int32 i = 0; i < SomeBody.Num(); ++i)
{
FVector origin = SomeBody*->RelativeLocation;
FString ChunkString = "0" + SomeBody*->GetName();
FName NameChunk = FName(*ChunkString);

SomeBody*->DestroyComponent(true);

UDestructibleComponent* DestructibleChunk = NewObject<UDestructibleComponent>(this, NameChunk);
DestructibleChunk->RegisterComponent();
DestructibleChunk->SetCollisionEnabled(ECollisionEnabled::PhysicsOnly);
DestructibleChunk->SetSimulatePhysics(true);
DestructibleChunk->SetEnableGravity(true);
DestructibleChunk->WakeRigidBody(NAME_None);

DestructibleChunk->SetSkeletalMesh(SklMesh, true);
DestructibleChunk->SetRelativeLocation(FVector(0, 0, 100)); //test pos
DestructibleChunk->Mobility = EComponentMobility::Static;
DestructibleChunk->AttachTo(SomeRootComponent);
DestructibleChunk->SetVisibility(true, true);
DestructibleChunk->Activate();

break; //just for testing
}
}

Problem is it’s not showing, at all, i can’t understand what’s the reasons of it… maybe y can give me a clue. :S

Okey, it worked, finally, i guess i gave up too early, sorry for posting. Created destructible mesh from sphere with _DM prefix and used:
DestructibleChunk->SetDestructibleMesh(SklMesh); with UDestructibleMesh class definition for SklMesh.

Okey, seems it’s not over. I made it work fine in Editor, but after packing to actual build APEX destruction doesn’t work.

Basicly it’s stuck on DestructibleChunk->SetDestructibleMesh according to minidump, can’t find DM object probably? but why…

Log info:


[2020.01.19-05.34.02:780][249]LogWindows: Error: === Critical error: ===
[2020.01.19-05.34.02:780][249]LogWindows: Error:
[2020.01.19-05.34.02:780][249]LogWindows: Error: Fatal error!
[2020.01.19-05.34.02:780][249]LogWindows: Error:
[2020.01.19-05.34.02:780][249]LogWindows: Error: Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x00000000
[2020.01.19-05.34.02:780][249]LogWindows: Error:
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f46aefc Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f9191b0 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f91591e Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f916dfb Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013fdce119 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013ff989c7 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x0000000141818c4b Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f460c18 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x0000000141a64219 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x0000000141a63bd4 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x0000000141a98e0d Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x0000000141a852bb Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x0000000141ad7fb2 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f919d9b Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f91a008 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x00000001418260bf Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x00000001418006c3 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000014239b166 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x00000001423b09c7 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f94e24d Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f94e4a3 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f95c9b2 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x00000001423f3507 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x00000001423ff3b2 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x0000000141d9cdff Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x0000000141da6336 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x0000000141c4601f Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f3f6bff Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f404cec Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f404d5a Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x000000013f413013 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x00000001433563e2 Game.exe!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x00000000779359cd kernel32.dll!UnknownFunction ]
[2020.01.19-05.34.02:780][249]LogWindows: Error: [Callstack] 0x0000000077a9383d ntdll.dll!UnknownFunction ]

This one i probably won’t figure out on my own cause in editor all works perfect… :SSS tried to put this into constructor, same results, after setting destructible mesh i’m getting crash (but in packed build only). Maybe needs some specific dependencies to set for destructibles? Will be greatfull for any clue.

What i tried in constructor:



    MyDMMesh = ConstructorHelpers::FObjectFinder<UDestructibleMesh>(TEXT("DestructibleMesh'/Game/SomeContent/Models/Sphere_DM.Sphere_DM'")).Object;
    UDestructibleComponent* DestructibleChunk = NewObject<UDestructibleComponent>(this, TEXT("TEST"));
    DestructibleChunk->SetDestructibleMesh(MyDMMesh);
    DestructibleChunk->SetRelativeLocation(FVector(0,0,72));

Was managed to get more detailed info to end of the day, the source of problem:


Exception thrown: read access violation.
NewMesh->ApexDestructibleAsset was nullptr.

But this doesn’t make any sense, at least i don’t get it.

Guy here had same problem: https://forums.unrealengine.com/deve…lptr-apexasset

Update:
Managed to fix it, basicly y just need to load your asset dynamicly, not in constructor, like so… for example:


UDestructibleMesh* Mesh = LoadObject<UDestructibleMesh>(NULL, TEXT("DestructibleMesh'/Game/SomeContent/Models/Sphere_DM.Sphere_DM'"));

According to info from here you can use:



 UClass* Result = StaticLoadClass(UObject::StaticClass(), nullptr, *ClassName, nullptr, LOAD_None, nullptr); 

to load FString, tho i didn’t get how to use it properly for this case probably cause of luck of knowledge of ue4 engine api and normal example, anyway first way should work.