Hey guys.
I’ve researched for hours on a solution to my current problem, but I can’t seem to find any solution. To quickly explain what I’m going for: I’ve made a interface for events, and I’m trying to inherit the interface on my custom GameState, so the GameState updates my in-game time and date speed multiplier.
When inherting I’m defining the base function as well as the override ‘_Implementation’ functionas my interface functions are BlueprintImplementableEvent. It’s easier to show than tell.
Interface:
#pragma once
#include "./Machines/ConstructableMaster.h"
#include "HUDInterface.generated.h"
// This class does not need to be modified.
UINTERFACE()
class UHUDInterface : public UInterface
{
GENERATED_UINTERFACE_BODY()
};
/**
*
*/
class COMPTECH_API IHUDInterface
{
GENERATED_IINTERFACE_BODY()
public:
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
void ConstructMachine(TSubclassOf<AConstructableMaster> Constructable);
UFUNCTION(BlueprintImplementableEvent, BlueprintCallable)
void UpdateGameSpeed(float Multiplier);
};
It’s the function void UpdateGameSpeed(float Multiplier)
that I wish to listen to.
Here’s my GameState
and my implementation of the function:
GameState.h
#pragma once
#include "GameFramework/GameStateBase.h"
#include "Interfaces/HUDInterface.h"
#include "ComptechGameState.generated.h"
/**
*
*/
UCLASS()
class COMPTECH_API AComptechGameState : public AGameStateBase, public IHUDInterface
{
GENERATED_BODY()
public:
// Constructor
AComptechGameState();
protected:
UFUNCTION()
virtual void BeginPlay() override;
UFUNCTION()
virtual void Tick(float DeltaTime) override;
public:
/** HUD interface **/
UFUNCTION(BlueprintNativeEvent)
void UpdateGameSpeed(float Multiplier);
virtual void UpdateGameSpeed_Implementation(float Multiplier) override;
};
All guides I’ve found shows this solution. When I implement this function in my .cpp
, I get the following error:
'AComptechGameState::UpdateGameSpeed_Implementation': method with override specifier 'override' did not override any base class methods
Here’s my implementation
GameState.cpp
#include "Comptech.h"
#include "ComptechGameState.h"
AComptechGameState::AComptechGameState()
{
// Game state should tick, and start with tick
PrimaryActorTick.bStartWithTickEnabled = true;
PrimaryActorTick.bCanEverTick = true;
}
void AComptechGameState::BeginPlay()
{
Super::BeginPlay();
}
void AComptechGameState::Tick(float DeltaTime)
{
Super::Tick(DeltaTime);
}
// Update game speed from HUD interface
void AComptechGameState::UpdateGameSpeed_Implementation(float Multiplier)
{
TimeUnit = DefaultGameSpeed * Multiplier;
//OnUpdateGameSpeedDelegate.Broadcast(TimeUnit);
}
I’m hoping that some of you guys could perhaps tell me what the issue is, since I’m at a loss and cannot see what’s wrong.
NOTE:
I’ve left in the ConstructMachine
since this WORKS. This is why I’m mostly confused. ConstructMachine
works but UpdateGameSpeed
doesn’t. The GameState
does not override the ConstructMachine
but I’ve managed to get that working just as a test