Can't Control ThirdPersonCharacter after Re-parent

Hey Everyone,
I’m very new to using unreal. My friends asked me to join them in making a game. I want to work as much in C++ as possible to improve my programming. So when i cloned the start of the game I found out that they began in the blueprint third person template. I created a character class and in in the ThirdPersonCharacter blueprint I re-parented to a c++ character class I had created. Now the character won’t move. I even copy and pasted the code created in the c++ 3rd person template and I still have no control.

here is the header:

#pragma once

#include "GameFramework/Character.h"
#include "DWCharacter.generated.h"

UCLASS()
class PROJECT_API ADWCharacter : public ACharacter
{
	GENERATED_BODY()
	//position camera behind player
	UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
	class USpringArmComponent* CameraBoom;

	//follow Camera
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera, meta = (AllowPrivateAccess = "true"))
	class UCameraComponent* FollowCamera;

public:
	// Sets default values for this character's properties
	ADWCharacter();

//base turn rate in degree per second
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
	float BaseTurnRate;

//base look up rate in degree per second
UPROPERTY(VisibleAnywhere, BlueprintReadOnly, Category = Camera)
	float BaseLookUpRate;

// Called when the game starts or when spawned
virtual void BeginPlay() override;

// Called every frame
virtual void Tick( float DeltaSeconds ) override;


protected:
	//move forward and backward
	void MoveForward(float Value);

//move left and right
void MoveRight(float Value);

//rate of turning 1.0 is 100 percent turn rate
void TurnAtRate(float Rate);

//rate of looking up/down
void LookUpAtRate(float Rate);

//handler for beginning of touch input
void TouchStarted(ETouchIndex::Type FingerIndex, FVector Location);

//handler for when touchinput stops

void TouchStopped(ETouchIndex::Type FingerIndex, FVector Location);

protected:

//APawn interface
virtual void SetupPlayerInputComponent(class UInputComponent* InputComponent) override;
//end of pawn interface

public:

//returns CameraBoom
FORCEINLINE class USpringArmComponent* GetCameraBoom() const { return CameraBoom; }
//returns FollowCamera
FORCEINLINE class UCameraComponent* GetFollowCamera() const { return FollowCamera; }	
};

and the implementation:

    #include "PROJECT.h"
    #include "DWCharacter.h"
    
    // Sets default values
    ADWCharacter::ADWCharacter()
    {
     	// Set this character to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
    	PrimaryActorTick.bCanEverTick = true;

	// Set size for collision capsule
	GetCapsuleComponent()->InitCapsuleSize(42.f, 96.0f);

	// set our turn rates for input
	BaseTurnRate = 45.f;
	BaseLookUpRate = 45.f;

	// Don't rotate when the controller rotates. Let that just affect the camera.
	bUseControllerRotationPitch = false;
	bUseControllerRotationYaw = false;
	bUseControllerRotationRoll = false;

	// Configure character movement
	GetCharacterMovement()->bOrientRotationToMovement = true; // Character moves in the direction of input...	
	GetCharacterMovement()->RotationRate = FRotator(0.0f, 540.0f, 0.0f); // ...at this rotation rate
	GetCharacterMovement()->JumpZVelocity = 600.f;
	GetCharacterMovement()->AirControl = 0.2f;

	// Create a camera boom (pulls in towards the player if there is a collision)
	CameraBoom = CreateDefaultSubobject<USpringArmComponent>(TEXT("CameraBoom"));
	CameraBoom->SetupAttachment(RootComponent);
	CameraBoom->TargetArmLength = 300.0f; // The camera follows at this distance behind the character	
	CameraBoom->bUsePawnControlRotation = true; // Rotate the arm based on the controller

												// Create a follow camera
	FollowCamera = CreateDefaultSubobject<UCameraComponent>(TEXT("FollowCamera"));
	FollowCamera->SetupAttachment(CameraBoom, USpringArmComponent::SocketName); // Attach the camera to the end of the boom and let the boom adjust to match the controller orientation
	FollowCamera->bUsePawnControlRotation = false; // Camera does not rotate relative to arm




}

// Called when the game starts or when spawned
void ADWCharacter::BeginPlay()
{
	Super::BeginPlay();

	//debug message to make sure we are using the DWCharacter
	GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Red, TEXT("DWCharacter In Use."));
	
}

// Called every frame
void ADWCharacter::Tick( float DeltaTime )
{
	Super::Tick( DeltaTime );

}

// Called to bind functionality to input
void ADWCharacter::SetupPlayerInputComponent(class UInputComponent* InputComponent)
{
	// Set up gameplay key bindings
	check(InputComponent);
	InputComponent->BindAction("Jump", IE_Pressed, this, &ACharacter::Jump);
	InputComponent->BindAction("Jump", IE_Released, this, &ACharacter::StopJumping);

	InputComponent->BindAxis("MoveForward", this, &ADWCharacter::MoveForward);
	InputComponent->BindAxis("MoveRight", this, &ADWCharacter::MoveRight);

	// We have 2 versions of the rotation bindings to handle different kinds of devices differently
	// "turn" handles devices that provide an absolute delta, such as a mouse.
	// "turnrate" is for devices that we choose to treat as a rate of change, such as an analog joystick
	InputComponent->BindAxis("Turn", this, &APawn::AddControllerYawInput);
	InputComponent->BindAxis("TurnRate", this, &ADWCharacter::TurnAtRate);
	InputComponent->BindAxis("LookUp", this, &APawn::AddControllerPitchInput);
	InputComponent->BindAxis("LookUpRate", this, &ADWCharacter::LookUpAtRate);

	// handle touch devices
	InputComponent->BindTouch(IE_Pressed, this, &ADWCharacter::TouchStarted);
	InputComponent->BindTouch(IE_Released, this, &ADWCharacter::TouchStopped);


}

void ADWCharacter::TouchStarted(ETouchIndex::Type FingerIndex, FVector Location)
{
	//jump on the first touch
	if (FingerIndex == ETouchIndex::Touch1)
	{
		Jump();
	}
}

void ADWCharacter::TouchStopped(ETouchIndex::Type FingerIndex, FVector Location)
{
	if (FingerIndex == ETouchIndex::Touch1)
	{
		StopJumping();
	}
}

void ADWCharacter::TurnAtRate(float Rate)
{
	//calculate delta for frame from rate info
	AddControllerYawInput(Rate * BaseTurnRate * GetWorld()->GetDeltaSeconds());
}

void ADWCharacter::LookUpAtRate(float Rate)
{
	//calculate delta for frame from rate info
	AddControllerPitchInput(Rate * BaseLookUpRate * GetWorld()->GetDeltaSeconds());
}

void ADWCharacter::MoveForward(float Value)
{
	if ((Controller != NULL) && (Value != 0.0f))
	{
		//find which way is forward
		const FRotator Rotation = Controller->GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);

		//get forward vector
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::X);
		AddMovementInput(Direction, Value);
	}
}

void ADWCharacter::MoveRight(float Value)
{
	if ((Controller != NULL) && (Value != 0.0f))
	{
		//find out which way is right
		const FRotator Rotation = Controller->GetControlRotation();
		const FRotator YawRotation(0, Rotation.Yaw, 0);

		//get right vector
		const FVector Direction = FRotationMatrix(YawRotation).GetUnitAxis(EAxis::Y);
		//add movement in direction
		AddMovementInput(Direction, Value);
	}
}

any help would be greatly appreciated…I can’t seem to find a solution.
thank you

Hey mukrumbus-

Can you make sure that the Game Mode is set to use the your character class as the Default Pawn? Additionally, if you remove the default character from the template level and replace with an instance of your class, are you able to control/move that character?

Hi ,
I believe my Game Mode has my character as default. I removed the default character with an instance of the blueprint of my character with:

static ConstructorHelpers::FClassFinderPlayerPawnObject(TEXT("Pawn'/Game/Blueprints/BP_DWCharacter.BP_DWCharacter_C'"));
	if (PlayerPawnObject.Class != NULL)
	{
		DefaultPawnClass = PlayerPawnObject.Class;
	}

I’m trying to just follow along the the FPS tutorial which i had work fine.

I am getting the debug message for my character. however i still cannot move him and i’m not even viewing through the character’s camera. Also, in the FPS Tutorial the character would spawn in, this does not occur here even though the code is nearly identical.

here are my game mode files:
header:

   #pragma once
#include "GameFramework/GameMode.h"
#include "DWGameMode.generated.h"

/**
*
*/
UCLASS()
class PROJECT_API ADWGameMode : public AGameMode
{
GENERATED_BODY()

	virtual void StartPlay() override;

//constructor
ADWGameMode(const FObjectInitializer& ObjectInitializer);

};

and the imp.:

#include "PROJECT.h"
#include "DWGameMode.h"
#include "Engine.h"
#include "DWCharacter.h"

ADWGameMode::ADWGameMode(const FObjectInitializer& ObjectInitializer) : Super(ObjectInitializer)
{
//choose default pawn class to spawn for player
//choose blueprint of DWCharacter
static ConstructorHelpers::FClassFinderPlayerPawnObject(TEXT(“Pawn’/Game/Blueprints/BP_DWCharacter.BP_DWCharacter_C’”));
if (PlayerPawnObject.Class != NULL)
{
DefaultPawnClass = PlayerPawnObject.Class;
}
}

void ADWGameMode::StartPlay()
{
Super::StartPlay();

StartMatch();

if (GEngine)
{
	//display a debug message for five seconds
	//the -1 "key" value (1st argument) indicates that we will never need to update or refresh this message.
	GEngine->AddOnScreenDebugMessage(-1, 5.0f, FColor::Yellow, TEXT("Hello World, this is the DWGameMode!"));
}

}

In your game mode constructor, try changing DefaultPawnClass = PlayerPawnObject.Class; to ADefaultPawnClass = DWCharacter::StaticClass(); and let me know if that has an affect. This test should load the class itself as your default pawn (rather than the blueprint).

This too did not work…the debug message for the DWCharacter appears, but i still have no control over the character.

After looking over the code you provided again, I noticed that a call to the parent class function for SetupPlayerInputComponent was missing. Adding Super::SetupPlayerInputComponent(InputComponent); at the beginning of your function call should help.

Cheers