I’m trying to create procedural objects with physics enabled, but I’m having a little trouble.
I’m creating a simple box, and I would like it to simply fall to the ground when the game starts.
This is the code:
TArray<FVector> mVertices;
TArray<int32> mIndices;
TArray<FVector> mNormals;
TArray<FVector2D> mUvs;
TArray<FProcMeshTangent> mTangents;
TArray<FColor> mVertexColors;
UKismetProceduralMeshLibrary::GenerateBoxMesh(FVector(100, 100, 100), mVertices, mIndices, mNormals, mUvs, mTangents);
mMesh->CreateMeshSection(0, mVertices, mIndices, mNormals, mUvs, mVertexColors, mTangents, true);
mMesh->RegisterComponent();
mMesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
mMesh->bUseComplexAsSimpleCollision = false;
mMesh->SetSimulatePhysics(true);
This is done in the BeginPlay() of some actor. When the game starts, the box does appear and it starts falling down from its initial position, like you would expect. The problem is that when it hits the floor or anything else it just keeps going.
I’m using the FPS Template as training room, which has other pre-made boxes around the level that have phyisics. I looked into their properties, and they’re the same as the procedural box. I don’t understand what I’m doing wrong.