UE4 Editing PlayerController.h Error

I made a third-person c++ project in UE4.

I want to add a function in Playercontroller.h and PlayerController.cpp that is

PlayerController.cpp

bool APlayerController::GetHitResultAtScreenPosition(const FVector2D ScreenPosition, const ECollisionChannel TraceChannel, const FCollisionQueryParams& CollisionQueryParams, FHitResult& HitResult, float HitTraceDistance) const
{
    if (GetHUD() != NULL && GetHUD()->GetHitBoxAtCoordinates(ScreenPosition, true))
    {
	return false;
    }

    FVector WorldOrigin;
    FVector WorldDirection;
    if (UGameplayStatics::DeprojectScreenToWorld(this, ScreenPosition, WorldOrigin, WorldDirection) == true)
    {
	    return GetWorld()->LineTraceSingleByChannel(HitResult, WorldOrigin, WorldOrigin + WorldDirection * HitTraceDistance, TraceChannel, CollisionQueryParams);
}

    return false;
}

PlayerController.h

bool GetHitResultAtScreenPosition(const FVector2D ScreenPosition, const ECollisionChannel TraceChannel, const FCollisionQueryParams& CollisionQueryParams, FHitResult& HitResult, float HitTraceDistance) const;

Very simply it should let me define a hit trace distance instead of the default value of 10000.0f.

However, when I compile this I get this error.

error LNK2019: unresolved external symbol "__declspec(dllimport) public: bool __cdecl APlayerController::GetHitResultAtScreenPosition(struct FVector2D,enum ECollisionChannel,struct FCollisionQueryParams const &,struct FHitResult &,float)const " (__imp_?GetHitResultAtScreenPosition@APlayerController@@QEBA_NUFVector2D@@W4ECollisionChannel@@AEBUFCollisionQueryParams@@AEAUFHitResult@@M@Z)

What exactly is this error and what can I do to resolve it?

You can only change the source code of the engine if you have downloaded the source and built the engine yourself. However you don’t need to do all this if you simply create a derived class of APlayerController and add your function in that.

You should avoid changing the source code of the engine whenever possible because it makes upgrading to a newer engine very cumbersome.