Hi again Garner
Sorry to bother you but I have been trying to implement it the way you said. I tried many things since last writing. But now I have written a custom PlayerController class so that I can have the ‘Team’ variable on that. The problem is it seems to get reset to the default values after using Seamless Travel from the Lobby map to the Main Game map.
void APuzzlePlatformsGameMode::PostLogin(APlayerController* NewPlayer)
{
Super::PostLogin(NewPlayer);
UE_LOG(LogTemp, Warning, TEXT("GMode: Game mode POSTLOGIN called"));
int team=(2-++NumberOfPlayers)%2;
APuzzPlatPlayerController* pCont=(APuzzPlatPlayerController*)NewPlayer;
if(pCont!=nullptr)
{
pCont->Team=5;
}
if(NumberOfPlayers>=2)
{
GetWorldTimerManager().SetTimer(GameStartTimer, this, &APuzzlePlatformsGameMode::StartGame, 2);
}
}
As a test I have these log messages in Tick for the PlayerMallet (ACharacter)
void APlayerMallet::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
if(GetWorld()==nullptr)
return;
APuzzPlatPlayerController* pCont = (APuzzPlatPlayerController*)GetWorld()->GetFirstPlayerController();
if(pCont!=nullptr)
{
int team=pCont->Team;
UE_LOG(LogTemp, Warning, TEXT("pCont (1st PCont) Team=%d"), team);
}
APuzzPlatPlayerController* pContLocal=(APuzzPlatPlayerController*)GetWorld()->GetFirstLocalPlayerFromController();
if(pContLocal!=nullptr)
{
int teamlocal=pContLocal->Team;
UE_LOG(LogTemp, Warning, TEXT("pCont (1st Local PCont) Team=%d"), teamlocal);
}
}
But the results are wrong for both. As you can see I tried to hard-code 5
as the Team, but whenever the Main game scene begins all those values are back at default 111
. Also the first of the two logs always gives 0
.
Here is the full project on Github. Its fairly small still in size i think. If you can be kind enough to sometime download it and see what I mean that would be awesome (I have truly spent hundreds of hours stuck on this one problem and really cannot think of any other way to workaround the problem)
c0de-m0nk3y/AirHockeySteam (github.com)
All the best and thanks for the help you have already given.
(A final edit: I also tried using a custom PlayerState as you suggest. But the same thing is happening where the values get reset back and also had problem setting the replication up on that object- the Github link now shows the project with this method setup but is still not working