I am currently working on a dynamic track system that generates a series of node actors along a dynamic path. Each node actor connects to the next through a USplineMeshComponent generated during construction in editor and BeginPlay during runtime. During Current Viewport, Mobile Preview, Mobile Preview, and Stand-along game the project works flawlessly as designed. When I Launch the project on a Samsung S8 Active android device the project crashes.
I have tracked the issue down to the static mesh collision. If I set the static mesh’s collision to Project Default or Use Simple as Complex then the project crashes on Launch. If I set the static mesh’s collision to Use Complex as Simple then it runs. Per mobile spline meshes don’t support collision on launch if using complex collision we need to be able to use Simple or custom collisions to get the collision working.
Our current setup uses custom collision meshes attached to the static mesh and works explicitly as designed.
Any leads on how to correct this issue or apply a work-around to allow use to use Simple custom collision meshes would be deeply appreciated.
Below are images of our current static mesh collision settings and the code that creates the USplineMeshComponents to connect the nodes.
void ALRMapNodeActor::ConnectToNode(ALRMapNodeActor *PrevNode, ALRMapNodeActor *NextNode, UStaticMesh *TrackMesh, UStaticMesh *LeftRailMesh, UStaticMesh *RightRailMesh)
{
if (NextNode != nullptr)
{
//Add spline from this node to next node
FName SplineName = FName(TEXT("ConnectionSpline"), TrackSplines.Num() + 1);
USplineComponent *Spline = NewObject<USplineComponent>(this, SplineName);
if (Spline != nullptr)
{
Spline->SetupAttachment(RootComponent);
Spline->RegisterComponent();
TrackSplines.Add(Spline);
//Setup start point and end point of spline
FVector StartLocation = GetActorLocation();
FVector EndLocation = NextNode->GetActorLocation();
FVector DirectionToNextNode = EndLocation - StartLocation;
DirectionToNextNode.Normalize();
//Calculate Tangents
FVector StartTangent = OutgoingTangent;
FVector EndTangent = NextNode->IncomingTangent;
Spline->SetLocationAtSplinePoint(0, StartLocation, ESplineCoordinateSpace::World);
Spline->SetTangentAtSplinePoint(0, StartTangent, ESplineCoordinateSpace::World);
Spline->SetLocationAtSplinePoint(1, EndLocation, ESplineCoordinateSpace::World);
Spline->SetTangentAtSplinePoint(1, EndTangent, ESplineCoordinateSpace::World);
//Draw Tangents
// DrawDebugLine(GetWorld(),StartLocation, StartLocation+(StartTangent), FColor::Red, true, 5.0f);
// DrawDebugLine(GetWorld(),EndLocation, EndLocation+(EndTangent), FColor::Purple, true, 5.0f);
if (TrackMesh != nullptr)
{
SplineMesh = NewObject<USplineMeshComponent>(this, FName("SplineMesh"));
if (SplineMesh != nullptr)
{
SplineMesh->SetupAttachment(RootComponent);
SplineMesh->RegisterComponent();
SplineMesh->SetMobility(EComponentMobility::Stationary);
SplineMesh->SetStaticMesh(TrackMesh);
SplineMesh->SetStartAndEnd(StartLocation, StartTangent, EndLocation, EndTangent);
SplineMesh->SetCollisionEnabled(ECollisionEnabled::QueryAndPhysics);
}
}
if (LeftRailMesh != nullptr)
{
LeftRailSplineMesh = NewObject<USplineMeshComponent>(this, FName("LeftRailSplineMesh"));
if (LeftRailSplineMesh != nullptr)
{
LeftRailSplineMesh->SetupAttachment(RootComponent);
LeftRailSplineMesh->RegisterComponent();
LeftRailSplineMesh->SetMobility(EComponentMobility::Stationary);
LeftRailSplineMesh->SetStaticMesh(LeftRailMesh);
LeftRailSplineMesh->SetStartAndEnd(StartLocation, StartTangent, EndLocation, EndTangent);
}
}
if (RightRailMesh != nullptr)
{
RightRailSplineMesh = NewObject<USplineMeshComponent>(this, FName("RightRailSplineMesh"));
if (RightRailSplineMesh != nullptr)
{
RightRailSplineMesh->SetupAttachment(RootComponent);
RightRailSplineMesh->RegisterComponent();
RightRailSplineMesh->SetMobility(EComponentMobility::Stationary);
RightRailSplineMesh->SetStaticMesh(RightRailMesh);
RightRailSplineMesh->SetStartAndEnd(StartLocation, StartTangent, EndLocation, EndTangent);
}
}
}
}
}
Android Logs showing failure:
[link text][3]