Can't figure out why I'm running into a breakpoint

I’m trying to figure out why this breakpoint is occurring. This is in the constructor to my player character. I’m on version 4.1

   CollisionComponent = PCIP.CreateDefaultSubobject<USphereComponent>(this, ADefaultPawn::CollisionComponentName);
   CollisionComponent->InitSphereRadius(35.0f);
   CollisionComponent->BodyInstance.bEnableCollision_DEPRECATED = true;
   static FName CollisionProfileName(TEXT("Pawn"));
   CollisionComponent->SetCollisionProfileName(CollisionProfileName);
   CollisionComponent->CanBeCharacterBase = ECB_No;
   CollisionComponent->bShouldUpdatePhysicsVolume = true;
    	
   SpringArm = PCIP.CreateDefaultSubobject<USpringArmComponent>(GetOuter(), TEXT("SpringArm0"));
   SpringArm->SetRelativeRotation( FRotator(0.f, 0.f, 0.f));
   SpringArm->AttachTo(RootComponent);
   SpringArm->TargetArmLength = 500.0f;
   MovementComponent = PCIP.CreateDefaultSubobject<UFloatingPawnMovement>(this, ADefaultPawn::MovementComponentName);
   MovementComponent->UpdatedComponent = CollisionComponent;
    	
   RootComponent = CollisionComponent;

   Camera = PCIP.CreateDefaultSubobject<UCameraComponent>(GetOuter(), TEXT("Camera0"));
   Camera->AttachTo(SpringArm, USpringArmComponent::SocketName);
   Camera->bUseControllerViewRotation = false;
   Camera->FieldOfView = 75.f;

If I leave the line RootComponent = CollisionComponent; at the end of the Movementcomponent/springarm block then I encounter only one breakpoint. It takes me to OutputDevice.cpp line 214 (specifically after pressing play in the editor). I’m not quite sure why. If I move the line RootComponent = CollisionComponent; to be between the definition of SpringArm and the end of the CollisionComponent block then I encounter a ton of breakpoints(to many to list, also before I press play in the editor). If I comment out the line RootComponent = CollisionComponent; then no breakpoints are encountered and my movement no longer works.

If I continue after encountering the breakpoint the game runs fine.

Has anyone else run into a similar issue or knows where to go from here. It works but I’d rather not have to leave something faulty in because the engine is able to handle a mistake I made in my code.

Thanks

Hi ghlkvf,

Could you provide the code from your .h file? Also, is this all of the code in your constructor?

Attached is the .h (in .txt form) file associated with the original code. The code in the original post is the entirety of the constructor for this PlayerPawn.

link text

i can’t even compile your source because of a linker error…

error LNK2001: unresolved external symbol “public: virtual void __cdecl APlayerPawn::SetupPlayerInputComponent(class UInputComponent *)” (?SetupPlayerInputComponent@APlayerPawn@@UEAAXPEAVUInputComponent@@@Z)

can you provide the whole *.cpp file?

PlayerPawn is just the name of the class, mostly arbitrary. As for setting up player input this is how I am doing it.

void APlayerPawn::SetupPlayerInputComponent(class UInputComponent* InputComponent){
	check(InputComponent);

	InputComponent->BindAxis("MoveRight", this, &APlayerPawn::MoveRight);
	InputComponent->BindAction("MoveUp", IE_Pressed, this, &APlayerPawn::OnJumpPressed);	//these will not be called as long as they are held down, one press is one call
	InputComponent->BindAction("MoveUp", IE_Released, this, &APlayerPawn::OnJumpReleased);	//one release is one call, the same method of movement for right and left will not work for the spacebar
}

Where the MoveRight and MoveUp are defined in the engine

crap… i need to rebuild debug editor… will take half a hour…

so i ran the code in debug and the exception is caused because the the pawn actor isn’t registered…

the problem is line 16:
RootComponent = CollisionComponent;

if the root component must be the sphere then here is something to read…
link text

and here:
link text

Please post an reply if you successfully changed the root component in code only…
i am curious but to tired to find out how to do it properly :slight_smile:

Thanks for the help Dave. Ive left the uni today already but ill take a look at what you linked tonight and look into it again in the morning. Ive also tried making it a capsule instead of a sphere but came to the same result.

Posting from my phone. Sorry for the terrible grammar/spelling.