How to disable all mouse input?

Hi,

Apologies for the long post regarding a basic question…

I’m currently working on a mouse only controlled basic board game. I created a playercontroller like so:

AMyGamePlayerController::AMyGamePlayerController(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	bShowMouseCursor = true;
	bEnableClickEvents = true;
	DefaultMouseCursor = EMouseCursor::Crosshairs;
}

and in my gameMode I have:

AMyGameGameMode::AMyGameGameMode(const class FPostConstructInitializeProperties& PCIP)
	: Super(PCIP)
{
	DefaultPawnClass = NULL;
	PlayerControllerClass = AMyGamePlayerController::StaticClass();
}

Verified all working fine by changing the MouseCursor types and confirm that it changes inside game and also confirmed my onClick function is properly responding to my click events.

My question is on how to disable all mouse input in case of a GameOver state?
I think I was able to get a reference to my game mode from inside the PlayGame() function. Then from inside my gameMode I would handle the new gameOver state by getting the PlayerController and either do:

PlayerController->SetCinematicMode(true, true, true);

or

PlayerController->DisableInput();

but, in both PlayerController cases above, the mouse input is still active and nothing gets disabled. I can still click and interact with my basic objects and shapes.

Here’s how I’m calling my gameMode from the PlayGame() function:

.....
if (someCondition == true)
{
	//Get a pointer to current GameMode
	AMyGameGameMode* CurrentGameMode = (AMyGameGameMode*)GetWorld()->GetAuthGameMode();

	//test string to show condition is met and game should be over
	FString someString = "GameOver";
	GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, someString);

	//call my GameMode->SetCurrentState and set state to GameOver
	CurrentGameMode->SetCurrentState(EMyGamePlayState::EGameOver);
}

Here’s some code inside my GameMode:

void AMyGameGameMode::SetCurrentState(EGamePlayState NewState)
{
	//See if GameMode SetCurrentState was called succesfully
	FString someString = "GameMode SetCurrentState Called";
	GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, someString);

	CurrentState = NewState;
	HandleNewState(NewState);
}

void AMyGameGameMode::HandleNewState(EGamePlayState NewState)
{
	switch (NewState)
	{
	case EGamePlayState::EPlaying:
			break;
	case EGamePlayState::EGameOver:
	{
		//See if we are inside GameMode->HandleNewState() GameOver siwtch case
		FString someString = "GameMode HandleNewState GameOver Switch case";
		GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, someString);

		APlayerController* PlayerController = UGameplayStatics::GetPlayerController(this, 0);
		PlayerController->DisableInput();
 		// or PlayerController->SetCinematicMode(true, true, true);

		//See if we reached break statement in GameMode->HandleNewState() GameOver siwtch case
		someString = "GameMode HandleNewState GameOver Switch case - REACHED BREAK";
		GEngine->AddOnScreenDebugMessage(-1, 2.f, FColor::Red, someString);*/

		break;
	}
	case EGamePlayState::EUnknown:
	default:
		break;
	}
}

Have you tried APlayerController->DisableInput() ?

Yes and still doesn’t work…it’s in the GameMode code above (lines 23 and 24)

My aplogies - I missed that.

Did you end up sorting this?

If I understand you correctly, you want to disable mouse click events and mouse over events? If yes, you should set the according values in your player controller:

// disable click and hover events
AMyPlayerController::bEnableClickEvents = 0;
AMyPlayerController::bEnableMouseOverEvents = 0;