Hello,
I’m facing an issue with instantiating SplineMeshComponent. In the BeginPlay of my GameMode, I’m instantiating SplineMeshComponent like this:
USplineMeshComponent* SplineMeshComponent = NewObject<USplineMeshComponent>(this, USplineMeshComponent::StaticClass());
if (SplineMeshComponent)
{
SplineMeshComponent->AttachToComponent(RootScene, FAttachmentTransformRules::KeepRelativeTransform);
SplineMeshComponent->RegisterComponent();
StartTangent = UKismetMathLibrary::ClampVectorSize(StartTangent, 0, MeshLength);
EndTangent = UKismetMathLibrary::ClampVectorSize(EndTangent, 0, MeshLength);
SplineMeshComponent->SetStaticMesh(Mesh);
SplineMeshComponent->SetStartAndEnd(StartPosition, StartTangent, EndPosition, EndTangent);
SplineMeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
AddInstanceComponent(SplineMeshComponent);
}
I instantiate many SplineMeshComponent one after the other for creating a ground procedurally.
When playing in the editor and in Standalone Game Mobile (from the Platforms menu), my character stands on the ground (collision is OK).
But after packaging for Android and playing on Mobile, my character goes through the ground (collision isn’t triggered). I tried by generating apk and installing it with the batch and by generating a bundle in google and installing it from the play store and in both I’m facing this issue.
I replaced SplineMeshComponent with StaticMeshComponent and with StaticMeshComponent it’s working on Mobile, my characters stand on ground.
UStaticMeshComponent* MeshComponent = NewObject<UStaticMeshComponent>(this, UStaticMeshComponent::StaticClass());
if (MeshComponent)
{
MeshComponent->AttachToComponent(RootScene, FAttachmentTransformRules::KeepRelativeTransform);
MeshComponent->RegisterComponent();
MeshComponent->SetStaticMesh(Mesh);
MeshComponent->SetRelativeLocation(StartPosition);
MeshComponent->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
}
As I have to curve my ground, I need SplineMeshComponent. So for now, I “fix” that by Spawning a StaticMesh just under the SplineMesh (1 cm) so that StaticMesh isn’t visible and give the illusion that character stay on the spline mesh ground.
So, is there a bug with SplineMeshComponent or is there some configuration or additionnal treatment for SplineMeshComponents that I missed ?
Thank you !