Hello
I have a bit of a problem with my spline meshes, If i call the Set Start and End function from my C++ class ( where im creating the spline mesh ) then the spline mesh wont have collision in a packaged game ( It does in the editor and in the Standalone Game mode )
If i call the function from a blueprint instead ( currently doing this on my construction script ), Then the spline mesh WILL have collision on a packaged game, Here is the code that im using
ATestTrackSplineActor.cpp
#include "ATestTrackSplineActor.h"
#include "Components/SplineComponent.h"
#include "Engine/CollisionProfile.h"
#include "Components/SplineMeshComponent.h"
// Sets default values
AATestTrackSplineActor::AATestTrackSplineActor()
{
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
PrimaryActorTick.bCanEverTick = true;
TrackSpline = CreateDefaultSubobject("TrackSpline");
if (TrackSpline != nullptr)
{
RootComponent = TrackSpline;
TrackSpline->SetMobility(EComponentMobility::Static);
}
}
void AATestTrackSplineActor::OnConstruction(const FTransform& Transform)
{
Super::OnConstruction(Transform);
}
// Called when the game starts or when spawned
void AATestTrackSplineActor::BeginPlay()
{
Super::BeginPlay();
}
// Called every frame
void AATestTrackSplineActor::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
void AATestTrackSplineActor::Func1()
{
for (int32 i = 0; i < TrackSpline->GetNumberOfSplinePoints() - 2; i++)
{
USplineMeshComponent* Piece;
FVector Start;
FVector StartTangent;
FVector End;
FVector EndTangent;
TrackSpline->GetLocationAndTangentAtSplinePoint(i, Start, StartTangent, ESplineCoordinateSpace::Local);
TrackSpline->GetLocationAndTangentAtSplinePoint(i + 1, End, EndTangent, ESplineCoordinateSpace::Local);
Piece = NewObject(this, TrackSplineMeshClass);
Piece->RegisterComponent();
Piece->SetStaticMesh(Mesh);
Piece->SetForwardAxis(ESplineMeshAxis::X, false);
Piece->AttachToComponent(TrackSpline, FAttachmentTransformRules::KeepRelativeTransform);
Piece->SetCollisionProfileName("BlockAll");
Piece->UpdateMesh();
Pieces.Add(Piece);
}
}
And here is the blueprint logic im running