Set Start and End wont update a Spline collision on a Packaged Game when called from a C++ class

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

I have a similar issue, but there is no collision after packaging if I use Set Start and End from Blueprints in game, e.g. after a 0.1s delay after Begin Play.

Update: Spline Mesh collision also doesn’t work when a spline mesh is spawned at runtime! I’m testing this now and I’ll make a bug report soon. I need to see if this also happens on earlier versions (I’m on 4.24).

Update 2: It looks like a bug in 4.24+, in 4.23 it works properly. I’ve reproduced this and reported through the bug submission form.
Here’s a simple repro project if you’re interesed:
https://app.box.com/s/6fo9ysf38r7vd8tgvjvjee6jdnh7ejeb

… Works ok in PIE, but the sphere falls through after packaging.

Just tested this in the 4.25, the bug i still there.

I’ve reported this bug, now you can track & vote for it here:

I’m necroing the thread a bit but I solved this by enabling “Allow CPUAccess” under General Settings for meshes that I used in my spline. UE 4.25.

Thank you for the info, that’s awesome. I can’t check it right now, but I’m sure it will help people with this issue, especially that the fix is scheduled for 4.27.

Hi everyone,

I just bumped into this issue and came across this thread.

No fix before 4.27 is really not cool, this should be targeted at 4.26 and would almost deserve a 4.25 hotfix imho.

Anyway, i can confirm the workaround works well in 4.25, so enormous thanks to all of you :slight_smile:

As some extra info for anyone reading this, the bAllowCPUAccess is public, and, as i load my meshes at runtime, i tried to fix it in the code with:


ModelMesh->bAllowCPUAccess = true;

Unfortunately, this resulted in a crash in the packaged game when setting the modified static mesh on the spline mesh component:


NewSplineMeshComponent->SetStaticMesh(ModelMesh);

For anyone interested (or having an idea for a solution), here’s the stack

So bottom line, this workaround works well but atm you’ll have to modify in the editor all the static meshes you need for your splines.

Thanks again,
Cheers
Cedric