For VR, I am trying to make a simple cube procedural mesh with a simple collision that always aligns with the four points of the cube. I would like the player be able to reshape this mesh at runtime by selecting and moving any of the four corners of the cube independently to a new location with the collision being updated to match.
So far, I have been unsuccessful with getting overlap events to occur with the procedural mesh collision.
To create the procedural mesh and collision, I use the Kismet ProcMesh function GenerateBoxMesh
, and then I select the simple box vertices from this mesh to create the collision.
Here is my setup code for vertices and collision where Mesh
is my procedural mesh:
Mesh = CreateDefaultSubobject<UProceduralMeshComponent> (TEXT("BoundsMesh"));
Mesh->AttachToComponent (RootComponent, FAttachmentTransformRules::KeepRelativeTransform);
UKismetProceduralMeshLibrary::GenerateBoxMesh ({ 25, 25, 25 }, MeshVertices, MeshTriangles, MeshNormals, MeshUVs, MeshTangents);
Mesh->SetMobility (EComponentMobility::Movable);
Mesh->SetCollisionEnabled (ECollisionEnabled::QueryOnly);
Mesh->SetCollisionObjectType (ECollisionChannel::ECC_WorldDynamic);
Mesh->SetGenerateOverlapEvents (true);
Mesh->bUseComplexAsSimpleCollision = false;
Mesh->CreateMeshSection (0, MeshVertices, MeshTrianlges, MeshNormals, MeshUVs, TArray<FColor>(), MeshTangents, true);
// Here we access the simple bounding 8 vertices of the cube
Mesh->AddCollisionConvexMesh ({ MeshVertices[0], MeshVertices[1], MeshVertices[2], MeshVertices[3],
MeshVertices[20], MeshVertices[21], MeshVertices[22], MeshVertices[23] });
In the UE editor, I see my expected collision settings in the inspector which have worked for other usages in my project. In the editor I also see the collision lines correctly bounding the box as I expect.
But, when playing in VR, I do not get any overlap events.
Anybody have any suggestions about this?
Is collision and overlap actually supported for Procedural Mesh Component?