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.