Functions calling each other in weird order

Sorry. I’m unable to wrap my head on this. I just don’t understand why you need to jump around and not do everything you need in the PC:

void AShooterController::Operation()
{
	AGameModeBase* GM = Cast<AGameModeBase>(UGameplayStatics::GetGameMode(GetWorld()));
	if (GM)
	{
		// do everything necessary here
		// call GM functions, set GM variables, set PC variables
	}	
}

Maybe someone else can help you, because I can’t. Sorry.

thats alright i figured it out in a empty project

Thank you for all your support EvilCleric

Again Thank you for your support EvilCleric

this is how i got it working

in this example what it does is get GM variable and set PC variable to be the same

and

the getGM sets the PC variable to the GM variable and TestVariableAmount function adds 1 to the variable and prints it out

character cpp

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

	AMyPlayerController* ShooterPC = Cast<AMyPlayerController>(UGameplayStatics::GetPlayerController(GetWorld(), 0));
	if (ShooterPC)
	{
		ShooterPC->getGM();
	}

}

PlayerController cpp

void AMyPlayerController::SetupInputComponent()
{
	Super::SetupInputComponent();

	InputComponent->BindAction("TestVariableAmount", IE_Pressed, this, &AMyPlayerController::TestVariableAmount);

	InputComponent->BindAction("ResetVariable", IE_Pressed, this, &AMyPlayerController::getGM);
}

void AMyPlayerController::getGM()
{
	AtesttodeleteGameModeBase* GM = Cast<AtesttodeleteGameModeBase>(UGameplayStatics::GetGameMode(GetWorld()));
	if (GM)
	{
		GM->GMFunc();
	}

}

void AMyPlayerController::ReturnGM(int32 value)
{
	PCVariable = value;

	FString IntAsString = FString::FromInt(NewVariable);

	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Orange, IntAsString);


}

void AMyPlayerController::TestVariableAmount()
{
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Orange, TEXT("NewVariable before adition"));
	FString IntAsString = FString::FromInt(PCVariable );

	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Orange, IntAsString);

	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Purple, TEXT("NewVariable + 1"));
	PCVariable += 1;

	FString SecondString= FString::FromInt(PCVariable );

	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Purple, SecondString);
}

GameMode cpp

AMyPlayerController* ShooterPC = Cast<AMyPlayerController>(UGameplayStatics::GetPlayerController(GetWorld(), 0));
if (ShooterPC)
{
	ShooterPC->ReturnGM(2);
}

**also ** i was using epics shooter example and the player controller couldn’t call function in gamemode

to fix this use this code inside the GetGM function

**also mportant ** you will need to create a new int32 in GM called GMvariable

if (GetWorld()->GetGameState())
{
	const AShooterGameMode* DefGame = GetWorld()->GetGameState()->GetDefaultGameMode<AShooterGameMode>();
	if (DefGame)
	{
		GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Purple, TEXT("GM call 2"));
		NewVariable = DefGame->GMvariable;
	}
}