I try to implement menu and I’m not sure of the step!
I created a C++ UserWidget and a child widget blueprint and created a menu with a start game button to begin. In the TankGameModeBase I created a blueprint implementable event GameMenu() so I can call it in BeginPlay. So after these steps everythings work but I’m not sure what to do after do I create a reference to TankGameModeBase in my UserWidget to call the HandleGameStart function?
Here what I had done in my UserWidget:
#include "MainMenuWidget.h"
#include "Components/Button.h"
#include "ToonTanks/GameModes/TankGameModeBase.h"
bool UMainMenuWidget::Initialize()
{
Super::Initialize();
UWorld* TheWorld = GetWorld();
if (TheWorld != nullptr)
{
//How do cast to Game mode?
GameMode = Cast<ATankGameModeBase>(UGameplayStatics::GetGameMode(TheWorld));
StartGame->OnClicked.AddDynamic(this, &UMainMenuWidget::StartButtonClicked);
return true;
}
}
void UMainMenuWidget::StartButtonClicked()
{
UE_LOG(LogTemp, Warning, TEXT("button working"));
}
Thank you for all your assistance and great thanks to GameDev.Tv for this course! The best I followed on Udemy!