So I am working on a script that adds meshes to a spline in the constructor.
But when compiling I keep getting a crash on the following line:
SMC->SetStartAndEnd(Start, StartTang, End, EndTang);
If that line is removed everything is working fine… Here is the full code.
ABSSpline::ABSSpline(const class FObjectInitializer& PCIP)
: Super(PCIP)
{
// 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;
SplineComponent = PCIP.CreateDefaultSubobject<USplineComponent>(this, TEXT("Spline"));
RootComponent = SplineComponent;
if (SplineComponent)
{
SplineComponent->SetMobility(EComponentMobility::Movable);
}
UStaticMesh* Cyl = Cast<UStaticMesh>(StaticLoadObject(UStaticMesh::StaticClass(), NULL, TEXT("/Engine/BasicShapes/Cylinder.Cylinder")));
for (int i = 0; i < SplineComponent->GetNumSplinePoints() - 2; i++)
{
SMC = PCIP.CreateDefaultSubobject<USplineMeshComponent>(this, TEXT("SplineMesh"));
SMC->SetStaticMesh(Cyl);
SMC->SetMobility(EComponentMobility::Movable);
SMC->ForwardAxis = ESplineMeshAxis::Z;
SMC->AttachTo(SplineComponent);
FVector Start, StartTang, End, EndTang;
SplineComponent->GetLocalLocationAndTangentAtSplinePoint(i, Start, StartTang);
SplineComponent->GetLocalLocationAndTangentAtSplinePoint(i+1, End, EndTang);
if (!Start.ContainsNaN() && !StartTang.ContainsNaN() && !End.ContainsNaN() && !EndTang.ContainsNaN())
{
SMC->SetStartAndEnd(Start, StartTang, End, EndTang);
}
}
}
The break is pointing to
bool UWorld::AreActorsInitialized() const
{
return PersistentLevel && PersistentLevel->Actors.Num() && bActorsInitialized;
}
In World.cpp
And the errors in the output I get is:
'UE4Editor.exe' (Win32): Loaded 'C:\Windows\System32\mswsock.dll'. Cannot find or open the PDB file.
'UE4Editor.exe' (Win32): Loaded 'D:\Projects\MobileApps\BallGame\Binaries\Win64\UE4Editor-BallGame.dll'. Symbols loaded.
First-chance exception at 0x00007FF984454F40 (UE4Editor-Engine.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000068.
Unhandled exception at 0x00007FF984454F40 (UE4Editor-Engine.dll) in UE4Editor.exe: 0xC0000005: Access violation reading location 0x0000000000000068.
But I have no clue what that has to do with anything…
Anyone who has an idea?