Included crash info. Usually problem was caused after attempting to “hot reload” a file that compiled in visual studio but brought an error in UE4. Typically “out_of_range” in regards to something if I recall. Love to get a fix so I could actually get through a tutorial in under 3 projects.
// Set this pawn to call Tick() every frame. You can turn this off to improve performance if you don’t need it.
PrimaryActorTick.bCanEverTick = true;
//Set pawn to be controlled by lowest-numbered player
AutoPossessPlayer = EAutoReceiveInput::Player0;
//Create dummy root component we can attach things to.
RootComponent = CreateDefaultSubobject<USceneComponent>(TEXT("RootComponent"));
//Create visible component
OurVisibleComponet = CreateDefaultSubobject<UStaticMeshComponent>(TEXT("OurVisibleComponent"));
//Attach camera and visible component to Root. Offset and rotate camera
OurVisibleComponet->AttachTo(RootComponent);
SphereComponent = CreateDefaultSubobject<USphereComponent>(TEXT("RootComponent"));
SphereComponent->AttachTo(RootComponent);
SphereComponent->InitSphereRadius(40.0f);
SphereComponent->SetCollisionProfileName(TEXT("Pawn"));
// Create a particle system that we can activate or deactivate
OurParticleSystem = CreateDefaultSubobject<UParticleSystemComponent>(TEXT("MovementParticles"));
OurParticleSystem->AttachTo(OurVisibleComponet);
OurParticleSystem->bAutoActivate = false;
OurParticleSystem->SetRelativeLocation(FVector(-20.0f, 0.0f, 20.0f));
//static ConstructorHelpers::FObjectFinder<UParticleSystem> ParticleAsset(TEXT("/Game/StarterContent/Particles/P_Fire.P_Fire"));
//if (ParticleAsset.Succeeded())
//{
// OurParticleSystem->SetTemplate(ParticleAsset.Object);
//}
SpringArm = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraAttachmentArm"));
SpringArm->AttachTo(RootComponent);
SpringArm->RelativeRotation = FRotator(-45.f, 0.f, 0.f);
SpringArm->TargetArmLength = 400.0f;
SpringArm->bEnableCameraLag = true;
SpringArm->CameraLagSpeed = 3.0f;
Camera = CreateDefaultSubobject<UCameraComponent>(TEXT("ActualCamera"));
Camera->AttachTo(SpringArm, USpringArmComponent::SocketName);
As you can see…I pretty much just followed: Components and Collision | Unreal Engine Documentation
tutorial. I have tried exactly copying the code and I get the same error. I made the changes I did as it seemed to mildly postpone the crash (I have about 3 projects with trying to do this tutorial. Each has the same crash error)
Looking at the callstack it seems that something in the construction script of AMyPawn is causing the issue. Can you post the code in the constructor of this class for more information? Additionally, does the project compile successfully in Visual Studio or does it give a compile error?
I recall it compiling perfectly in Visual Studio but when it loaded into UE4 the project crashed. I’ve tried moving the project folder and deleting the derived data cache, to no avail.
Changed the line, recompiled in Visual studio and tada. Everything survived. Thank you very much. As the crash wasn’t very informative may I suggest that some sort of…handling of this for future versions. I’m thinking of others mostly.
Thank you again.
There are two lines of conflicting code. The line that begins with RootComponent = and the line that begins with SphereComponent = both have “RootComponent” inside the TEXT() macro. This string is the friendly name for the component which must be unique. Both components sharing the same friendly name is what is causing the conflict. If you change the text inside either one to another name it should solve your issue.