ProceduralMeshComponent doesn't collide with anything

I’m trying to create procedural objects that collide with the world, but I can’t make it work.

I’m creating a simple box, with physics disabled; I’m using the First Person C++ template as testing room.

This is the code, executed on an Actor when the game starts:



    TArray<FVector> mVertices;
    TArray<int32> mIndices;
    TArray<FVector> mNormals;
    TArray<FVector2D> mUvs;
    TArray<FProcMeshTangent> mTangents;
    TArray<FColor> mVertexColors;

    mMesh->bUseComplexAsSimpleCollision = false;


    mMesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
    mMesh->SetCollisionResponseToAllChannels(ECollisionResponse::ECR_Block);
    mMesh->SetCollisionObjectType(ECollisionChannel::ECC_PhysicsBody);

    UKismetProceduralMeshLibrary::GenerateBoxMesh(FVector(100, 100, 100), mVertices, mIndices, mNormals, mUvs, mTangents);
    mMesh->CreateMeshSection(0, mVertices, mIndices, mNormals, mUvs, mVertexColors, mTangents, true);

    mMesh->RegisterComponent();


Then I’m grabbing pre-made cubes that are in the scene and I move them so that they should hit the procedural cube; except that they don’t, they pass right through it.

If I grab the procedural cube and move it around, it doesn’t hit anything. If I enable “simulate physics” on the procedural cube, it just fall through the ground.