I’m trying to override a few C++ functions in blueprints by making them Blueprint Implementable Events. I learned that for ufunctions to be overridden in blueprint they can’t be virtual, which I find super strange. So I removed the keyword virtual from my ufunctions and now I only get link errors when I compile. I tried cleaning and rebuilding in visual studio; no result. I tried commenting them out, compile successful, uncommented them, and compile failed as before. I even tried renaming them and compilation still failed. I removed the BlueprintImplementablEvent field from the macro and it compiled correctly. So okay there’s something weird with that I guess. But I even tried BlueprintNativeEvent and I get teh same failed results. So I’m not sure what to do next.
1>PastryPanzerPanic.generated.cpp.obj : error LNK2005: "public: void __cdecl UBuff::OnCreation(void)" (?OnCreation@UBuff@@QEAAXXZ) already defined in Buff.cpp.obj
1>PastryPanzerPanic.generated.cpp.obj : error LNK2005: "public: void __cdecl UBuff::OnDestroy(void)" (?OnDestroy@UBuff@@QEAAXXZ) already defined in Buff.cpp.obj
1>PastryPanzerPanic.generated.cpp.obj : error LNK2005: "public: void __cdecl UBuff::OnTick(void)" (?OnTick@UBuff@@QEAAXXZ) already defined in Buff.cpp.obj
1> Creating library S:\DysanianDawnWorkspace\PastryPanzerPanic\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-PastryPanzerPanic.lib and object S:\DysanianDawnWorkspace\PastryPanzerPanic\Intermediate\Build\Win64\UE4Editor\Development\UE4Editor-PastryPanzerPanic.exp
1>S:\DysanianDawnWorkspace\PastryPanzerPanic\Binaries\Win64\UE4Editor-PastryPanzerPanic.dll : fatal error LNK1169: one or more multiply defined symbols found
1>ERROR : UBT error : Failed to produce item: S:\DysanianDawnWorkspace\PastryPanzerPanic\Binaries\Win64\UE4Editor-PastryPanzerPanic.dll
1> Total build time: 53.19 seconds
1>C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.MakeFile.Targets(46,5): error MSB3073: The command ""D:\UnrealEngine\Epic Games\4.14\Engine\Build\BatchFiles\Rebuild.bat" PastryPanzerPanicEditor Win64 Development "S:\DysanianDawnWorkspace\PastryPanzerPanic\PastryPanzerPanic.uproject" -waitmutex" exited with code -1.
========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
// Buff.h
#pragma once
#include "../Tank.h"
#include "UObject/NoExportTypes.h"
#include "Buff.generated.h"
UCLASS(Blueprintable)
class PASTRYPANZERPANIC_API UBuff : public UObject
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Buff", Meta=(ExposeOnSpawn=true))
float lifeSpan;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Buff", Meta=(ExposeOnSpawn=true))
float timeCreated;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Buff", Meta=(ExposeOnSpawn=true))
float tickRate;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Buff", Meta=(ExposeOnSpawn=true))
float timeActive;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Buff", Meta=(ExposeOnSpawn=true))
bool bCanExpire;
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category="Buff", Meta=(ExposeOnSpawn=true))
class ATank *owningTank;
public:
UBuff();
UFUNCTION(BlueprintNativeEvent, Category="Buff")
void OnCreation();
UFUNCTION(BlueprintNativeEvent, Category="Buff")
void OnTick();
UFUNCTION(BlueprintNativeEvent, Category="Buff")
void OnDestroy();
};
// Buff.cpp
#include "PastryPanzerPanic.h"
#include "Buff.h"
UBuff::UBuff(){
}
void UBuff::OnCreation(){
// FTimerHandle buffTimer;
//
// if(tickRate > 0.f){
// GetWorldTimerManager().SetTimer(buffTimer, this, &UBuff::OnTick, tickRate, true);
// }
//
// owningTank->activeBuffs.Add(this);
//
// GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor:Blue, "Buff Created.");
}
void UBuff::OnTick(){
// GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor:Yellow, "Buff Ticking.");
// timeActive += tickRate;
// if(timeActive > lifeSpan){
// this->OnDestroy();
// }
}
void UBuff::OnDestroy(){
// GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor:Red, "Destroy Called.");
// GetWorldTimerManager().ClearTimer(buffTimer);
// owningTank->activeBuffs.Remove(this);
// Destroy();
}