Implementing jump

Ok I got it to work by casting it:



void AMainCharacterKeyboard::BeginPlay()
{
	Super::BeginPlay();

	ACharacter* Pawn = Cast<ACharacter>(GetPawn());
	//Pawn = GetPawn();
	this->Possess(Pawn);

	// sprint timer
	GetWorldTimerManager().SetTimer(SprintTimer, this, &AMainCharacterKeyboard::SprintTimerHandler, 1.0f, true);
};


Is there a better way to separate the Character and the character controls to how I’ve done it? Basically I want to have a class for every peripheral e.g. keyboard and controller and for them to automatically switch when the other is used.