# Player Controller functions not calling

**URL:** <https://forums.unrealengine.com/t/player-controller-functions-not-calling/143767>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [May 16, 2020, 4:22pm UTC](https://forums.unrealengine.com/t/player-controller-functions-not-calling/143767 "2020-05-16T16:22:34Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![anonymous\_user\_46dc83731](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_46dc83731](https://forums.unrealengine.com/u/anonymous_user_46dc83731)\
**Post date:** [May 16, 2020, 4:22pm UTC](https://forums.unrealengine.com/t/player-controller-functions-not-calling/143767/1 "2020-05-16T16:22:34Z")

</div>

Hi all, I’ve put debug messages in my player controllers functions and none of them except the constructor are calling. If anyone can help, it will be much appreciated, thank you 🙂

Heres the code:

PlayerCharacterController.h:

```auto

#pragma once

#include "CoreMinimal.h"
#include "GameFramework/PlayerController.h"
#include "PlayerCharacterController.generated.h"

class APlayerCharacter;

UCLASS()
class GUARDIANSOFSUNSHINE_API APlayerCharacterController : public APlayerController
{
GENERATED_BODY()

public:
APlayerCharacterController(const FObjectInitializer& PCIP);

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

void UpdateCharacter();
void UpdateAnimation();

// The paper sprite component that will hold our idle sprite when it is needed
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IdleSprite")
class UPaperSpriteComponent* IdleSpriteComponent;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "IdleSprite")
class UPaperSprite* IdleSprite;

// The animated flipbook that will have our walking animation
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PaperFlipbook")
class UPaperFlipbookComponent* WalkingComponent;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PaperFlipbook")
class UPaperFlipbook* WalkingAnimation;

// The animated flipbook that will have our jumping animation
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PaperFlipbook")
class UPaperFlipbookComponent* JumpingComponent;

UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "PaperFlipbook")
class UPaperFlipbook* JumpingAnimation;

// Player references
UPROPERTY(EditAnywhere)
TSubclassOf<APlayerCharacter> PlayerCharacterObject;

APlayerCharacter* PlayerCharacter;

// Movement functions
UFUNCTION()
virtual void SetupInputComponent() override;

void MoveHorizontal(float Value);

};

```

PlayerCharacterController.cpp:

```auto

#include "PlayerCharacterController.h"

#include "PlayerCharacter.h"
#include "GameFramework/Controller.h"

#include "PaperFlipbookComponent.h"
#include "PaperSpriteComponent.h"

#include "Engine.h"

#define print(text) if (GEngine) GEngine->AddOnScreenDebugMessage(-1, 1.5, FColor::Green, text)

APlayerCharacterController::APlayerCharacterController(const FObjectInitializer& PCIP) : Super(PCIP)
{
PrimaryActorTick.bCanEverTick = true;
PrimaryActorTick.bStartWithTickEnabled = true;

IdleSpriteComponent = PCIP.CreateDefaultSubobject<UPaperSpriteComponent>(this, TEXT("IdleSpriteComponent"));

WalkingComponent = PCIP.CreateDefaultSubobject<UPaperFlipbookComponent>(this, TEXT("WalkingComponent"));

JumpingComponent = PCIP.CreateDefaultSubobject<UPaperFlipbookComponent>(this, TEXT("JumpingComponent"));

// Get a reference to the PlayerCharacter
if (PlayerCharacterObject)
{
PlayerCharacter = Cast<APlayerCharacter>(PlayerCharacterObject);
}
}

void APlayerCharacterController::PlayerTick(float DeltaTime)
{
Super::PlayerTick(DeltaTime);

print("PlayerTick");

if (PlayerCharacter)
{
UpdateCharacter();
}
}

void APlayerCharacterController::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
print("Tick");
}

void APlayerCharacterController::SetupInputComponent()
{
Super::SetupInputComponent();

EnableInput(this);

print("Input");

InputComponent->BindAxis("MoveHorizontal", this, &APlayerCharacterController::MoveHorizontal);

}

void APlayerCharacterController::MoveHorizontal(float Value)
{
print("Moving");
if (PlayerCharacter)
{
PlayerCharacter->MoveHorizontal(Value);
}
}

void APlayerCharacterController::UpdateAnimation()
{

}

void APlayerCharacterController::UpdateCharacter()
{
// Update animation to match the motion
UpdateAnimation();

const FVector PlayerVelocity = PlayerCharacter->GetVelocity();
float TravelDirection = PlayerVelocity.X;

print(FString::SanitizeFloat(TravelDirection));

}

```

---

<div class="post-metadata">

**Author:** ![Jambax](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/jambax/32/904177_2.png) [@Jambax](https://forums.unrealengine.com/u/Jambax)\
**Post date:** [May 16, 2020, 7:00pm UTC](https://forums.unrealengine.com/t/player-controller-functions-not-calling/143767/2 "2020-05-16T19:00:10Z")

</div>

The most likely scenario is that you haven’t told the GameMode to use your custom Player Controller class.

> **[Game Mode and Game State](https://docs.unrealengine.com/4.27/en-US/InteractiveExperiences/Framework/GameMode/)**
>
> Overview of the Game Mode and Game State

---

<div class="post-metadata">

**Author:** ![anonymous\_user\_46dc83731](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_46dc83731](https://forums.unrealengine.com/u/anonymous_user_46dc83731)\
**Post date:** [May 17, 2020, 7:10am UTC](https://forums.unrealengine.com/t/player-controller-functions-not-calling/143767/3 "2020-05-17T07:10:02Z")

</div>

> [@](#):
>
> The most likely scenario is that you haven’t told the GameMode to use your custom Player Controller class.
> 
> [Game Mode and Game State in Unreal Engine | Unreal Engine 5.3 Documentation](https://docs.unrealengine.com/en-US/Gameplay/Framework/GameMode/index.html)

Thank you so much, that was such a silly mistake of me that I stupidly overlooked, appreciate the time saver 🙂
