I need help with the endgame widget

so I am gonna place a photo here with the issue. If u need more information reply and I will send all the screenshots u need. Please help me with this, I went through all the project and didn’t find what could cause the issue.

so basically when I lose I can press the buttons and they work normally but when I win the buttons don’t work. why is that happening?

How don’t they work? Can you press them at all? Does clicking them do nothing? Does clicking them do something else?

clicking them and hovering the mouse over them does nothing

this is my hierarchy image and this is the event graph:

And your game mode code?

// Fill out your copyright notice in the Description page of Project Settings.


#include "TankGameModeBase.h"
#include "ToonTanks/Pawns/PawnTank.h"
#include "TimerManager.h"
#include "ToonTanks/Pawns/PawnTurret.h"
#include "GameFramework/PlayerController.h"
#include "ToonTanks/PlayerControllers/PlayerControllerBase.h"
#include "Engine/World.h"
#include "Kismet/GameplayStatics.h"

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

	HandleGameStart();
}

void ATankGameModeBase::ActorDied(AActor* DeadActor)
{
	if (DeadActor == PlayerTank) {
		PlayerTank->HandleDestruction();
		HandleGameOver(false);

		if (PlayerControllerRef) {
			PlayerControllerRef->SetPlayerEnabledState(false);

		}
	}
	else {
		if (APawnTurret* DestroyedTurret=Cast<APawnTurret>(DeadActor)) {
			DestroyedTurret->HandleDestruction();
			if (--TargetTurrets == 0) {
				HandleGameOver(true);
			}
		}
	}
}

int32 ATankGameModeBase::GetTargetTurretCount()
{
	TArray<AActor*> TurretActors;
	UGameplayStatics::GetAllActorsOfClass(GetWorld(), APawnTurret::StaticClass(), TurretActors);
	return TurretActors.Num();
}

void ATankGameModeBase::HandleGameStart()
{
	PlayerControllerRef = Cast<APlayerControllerBase>(UGameplayStatics::GetPlayerController(this, 0));

	PlayerTank = Cast<APawnTank>(UGameplayStatics::GetPlayerPawn(this, 0));

	TargetTurrets = GetTargetTurretCount();

	GameStart();
	}


void ATankGameModeBase::HandleGameOver(bool PlayerWon)
{
	GameOver(PlayerWon);
}



I don’t need help anymore. I solved it myself. I just made 2 separate widgets. one for the win state and one for the lost state.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms