While testing actor runtime spawning, I’ve unfortunately encountered an error which I don’t understand at all.
I have a fully empty project except for AMyTestActor cpp and header files with a tiny bit of code within.
The code snippet:
SphereComponent = GetWorld()->SpawnActor<USphereComponent>(FVector(0.f, 0.f, 100.f), FRotator(0.f,0.f,0.f), FActorSpawnParameters());
if (SphereComponent) {
SphereComponent->InitSphereRadius(100.f);
SphereComponent->SetCollisionProfileName(UCollisionProfile::BlockAllDynamic_ProfileName);
SphereComponent->SetHiddenInGame(false);
}
That’s all the handwritten code in the project, so there’s nothing else what can be the source of the error.
Compiling this code results in editor shutdown with error “Access violation - code c0000005 (first/second chance not available)”. Moveover, the editor can’t even launch until I delete builded and source files.
AFAIK this error is related to accessing wrong memory/null pointer, but I cannot understand what can cause the error here and why it happens in the editor, when it supposed to appear during the runtime.
What am I missing?