I have a function that generates a spline track randomly and then fill in that spline with a mesh in the OnConstruction function so i can have sort of a road. I have collision working properly in the editor when i play, but it doesn’t have collision in cooked build. I have no idea why it’s doing that.
I have seen many threads created about this but no solution seem to have been found yet. I build my spline using a function adding points with the AddSplinePoint function, then i associate a mesh to the spline like this:
for (int32 i = 0; i < PathSpline->GetNumberOfSplinePoints() - 1; i++)
{
USplineMeshComponent* SplineMeshTmp = ConstructObject<USplineMeshComponent>(USplineMeshComponent::StaticClass(), this);
//USplineMeshComponent* SplineMeshTmp = NewObject<USplineMeshComponent>();
SplineMesh.Add(SplineMeshTmp);
SplineMesh.Last()->CreationMethod = EComponentCreationMethod::UserConstructionScript;
SplineMesh.Last()->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
SplineMesh.Last()->SetMobility(EComponentMobility::Movable);
SplineMesh.Last()->SetStaticMesh(NewMeshComponent->StaticMesh);
SplineMesh.Last()->SetVisibility(true);
SplineMesh.Last()->AttachParent = PathSpline;
//UMaterialInstanceDynamic* dynamicMat = UMaterialInstanceDynamic::Create(TheMaterial, NULL);
//SplineMesh->SetMaterial(0, dynamicMat);
FVector pointLocationStart, pointTangentStart, pointLocationEnd, pointTangentEnd;
PathSpline->GetLocalLocationAndTangentAtSplinePoint(i, pointLocationStart, pointTangentStart);
PathSpline->GetLocalLocationAndTangentAtSplinePoint(i + 1, pointLocationEnd, pointTangentEnd);
SplineMesh.Last()->SetStartAndEnd(pointLocationStart, pointTangentStart, pointLocationEnd, pointTangentEnd);
}
RegisterAllComponents();
what am i doing wrong? thank you