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

**URL:** <https://forums.unrealengine.com/t/set-start-and-end-wont-update-a-spline-collision-on-a-packaged-game-when-called-from-a-c-class/121538>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [January 24, 2019, 4:55pm UTC](https://forums.unrealengine.com/t/set-start-and-end-wont-update-a-spline-collision-on-a-packaged-game-when-called-from-a-c-class/121538 "2019-01-24T16:55:41Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![alvarofer0020](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@alvarofer0020](https://forums.unrealengine.com/u/alvarofer0020)\
**Post date:** [January 24, 2019, 4:55pm UTC](https://forums.unrealengine.com/t/set-start-and-end-wont-update-a-spline-collision-on-a-packaged-game-when-called-from-a-c-class/121538/1 "2019-01-24T16:55:41Z")

</div>

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

```auto

#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

 ![Spline.png](https://d3kjluh73b9h9o.cloudfront.net/original/3X/0/c/0cf8c7c3fe084a50da7f75d0ddbda55f982c618c.png)

---

<div class="post-metadata">

**Author:** ![Slavq](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slavq](https://forums.unrealengine.com/u/Slavq)\
**Post date:** [April 30, 2020, 8:38pm UTC](https://forums.unrealengine.com/t/set-start-and-end-wont-update-a-spline-collision-on-a-packaged-game-when-called-from-a-c-class/121538/2 "2020-04-30T20:38:02Z")

</div>

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](https://app.box.com/s/6fo9ysf38r7vd8tgvjvjee6jdnh7ejeb)

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

---

<div class="post-metadata">

**Author:** ![Slavq](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slavq](https://forums.unrealengine.com/u/Slavq)\
**Post date:** [May 5, 2020, 9:43pm UTC](https://forums.unrealengine.com/t/set-start-and-end-wont-update-a-spline-collision-on-a-packaged-game-when-called-from-a-c-class/121538/3 "2020-05-05T21:43:26Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Slavq](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slavq](https://forums.unrealengine.com/u/Slavq)\
**Post date:** [May 18, 2020, 2:53pm UTC](https://forums.unrealengine.com/t/set-start-and-end-wont-update-a-spline-collision-on-a-packaged-game-when-called-from-a-c-class/121538/4 "2020-05-18T14:53:20Z")

</div>

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

> **[The Unreal Engine Issues and Bug Tracker](https://issues.unrealengine.com/issue/UE-93234)**
>
> Welcome to the Unreal Engine Issue and Bug Tracker. You can check the status of an issue and search for existing bugs. See latest bug fixes too.

---

<div class="post-metadata">

**Author:** ![Metalwrath](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/metalwrath/32/741996_2.png) [@Metalwrath](https://forums.unrealengine.com/u/Metalwrath)\
**Post date:** [August 27, 2020, 10:37am UTC](https://forums.unrealengine.com/t/set-start-and-end-wont-update-a-spline-collision-on-a-packaged-game-when-called-from-a-c-class/121538/5 "2020-08-27T10:37:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Slavq](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Slavq](https://forums.unrealengine.com/u/Slavq)\
**Post date:** [August 28, 2020, 1:32pm UTC](https://forums.unrealengine.com/t/set-start-and-end-wont-update-a-spline-collision-on-a-packaged-game-when-called-from-a-c-class/121538/6 "2020-08-28T13:32:06Z")

</div>

> [@Metalwrath](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![uced](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@uced](https://forums.unrealengine.com/u/uced)\
**Post date:** [March 1, 2021, 11:24am UTC](https://forums.unrealengine.com/t/set-start-and-end-wont-update-a-spline-collision-on-a-packaged-game-when-called-from-a-c-class/121538/7 "2021-03-01T11:24:13Z")

</div>

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 🙂

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:

```auto

ModelMesh->bAllowCPUAccess = true;

```

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

```auto

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
