How to possess antother Pawn from same BP at Runtime?

Hello all together,
i have spend some serious time on this and cant get it working. Even after hours searching here.

I wanna do a simple thing. In the ThirdPerson-Template, i have the given starting Character in the Game. I took the BP of the Character and dragged another Character in the Game. So i have two Characters from the same Class and BP in the Editor. Now i just want to switch from one to the other per buttonclick.

I created a Custom PlayerController, which was supposed to manage that. Default-PlayerController in GameMode is working, like SetupInputComponent. Here are the two functions to swap chars from my Custom PlayerController.

void APlayerC::changeToMain()
{
	ASimpleCharacter * character = Cast<ASimpleCharacter>(UGameplayStatics::GetPlayerPawn(this, 0));
	if (character)
	{
		Possess(character);
	}
}


void APlayerC::changeToSecondary()
{

	UE_LOG(LogTemp, Log, TEXT("In Secondary!"));
	ASimpleCharacter * character = Cast<ASimpleCharacter>(UGameplayStatics::GetPlayerPawn(this, 1));
	if (character)
	{
		UE_LOG(LogTemp, Log, TEXT("and has character"));
		UnPossess();
		Possess(character);
	}
}

The changeToMain function seems to work, because on click it resets the Camera. But Secondary isnt working. I thought casting to the second PlayerPawn would be the right thing, but he cant find anything.

i know there are a lot of approaches, but is mine even possible or are there much better Solutions?

I appreciate every help i get.

GameplayStatics::GetPlayerPawn(this, x);

This doesn’t do what you think. It doesn’t check the world for playable characters and return the one at index x. It grabs the xth player controller and gets the pawn reference from that. So, if you’ve just got 1 PC, 0 will always return your currently possessed pawn and 1 will always return null (because there is no second PC.)

What you could do is use UGameplayStatics::GetAllActorsOfClass(). You’ll get an array (of 2 objects.) Posses the one you aren’t currently possessing.

Thanks TTaM,
i knew there was something wrong with it, but couldnt point at it. I will try ur Solution right away.
Thx again pal