Hello, I’ve created a C++ class that inherits from UUserWidget called PlayerHUD. I created a blueprint from it inside Unreal, and have bound some TextBlocks to it so that I can update the TextBlock values using C++. The PlayerHUD is only displayed once certain conditions are met, and once they are met, I call a function inside my Player Pawn’s C++ file to add the PlayerHUD to the player screen:
Inside my blueprint based on PlayerHUD.cpp, I have the following inside the event graph:
The GameMode that I’m casting to has two public variables that I’m using to determine whether or not to display a countdown timer on the screen, which are bool GameModeSelected and an FTimerHandle CountDown.
My main question is: How would I go about replacing Event Tick with something more efficient? I’m not well versed enough in Blueprints to know if I should use a Custom Event, Event Dispatcher, or some sort of dynamic delegate that I set up inside C++. Also, would it be better practice to include the above event graph inside of the Player pawn blueprint instead of the PlayerHUD blueprint?
Inside my GameMode.cpp, if I could simply reach a certain point in my code, I would like to communicate to my blueprint and tell it that it is now time to perform the event graph that I included in the screenshot. Specifically, this is the function where I would like that to happen:
template <class T>
void ABeatAimGameModeBase::HandleGameStart(T* GameModeSelector)
{
if (GameModeSelector->IsA(ASpiderShotSelector::StaticClass()))
{
GameModeSelected = true;
ResetPlayerStats();
ShowPlayerHUD();
GetWorldTimerManager().SetTimer(CountDown, this, &ABeatAimGameModeBase::StartSpiderShot, 3.f, false);
}
}
I could probably just implement all of it inside C++ instead of partially using blueprints, but I think its important for me to learn how I might go about solving this problem.
Thanks,
Mark