Hello:
I’m working on android game, using ASUS Zenfone3 as my device.
I have an array of FVector, which is going to add to a procedural mesh as a collision box .
Everything works fine when playing in editor. But it crashed when I played on my device.
I found out the problem is at AddCollisionConvexMesh. It won’t crash if I delete this line, but the procedural mesh must have collision mesh so this line can’t be deleted.
Why it works fine in Editor but not on device?
void CreateCollisionBox(float MaxUpLength, float MaxRightLength, float MaxForwardLength) {
// Clear any existing collision hulls
ProcMeshComponent->ClearCollisionConvexMeshes();
// Create collision box
TArray<FVector> SimpleCollisionBox;
for (int i = 0; i < 2; i++) {
for (int j = -1; j < 2; j += 2) {
for (int k = -1; k < 2; k += 2) {
SimpleCollisionBox.Add(
ProcMeshComponent->GetUpVector() * MaxUpLength * i +
ProcMeshComponent->GetRightVector() * MaxRightLength * j +
ProcMeshComponent->GetForwardVector() * MaxForwardLength * k);
}
}
}
ProcMeshComponent->bUseComplexAsSimpleCollision = false;
//Crashes on device
ProcMeshComponent->AddCollisionConvexMesh(SimpleCollisionBox);
ProcMeshComponent->SetSimulatePhysics(true);
ProcMeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
}