DECLARE_DYNAMIC_MULTICAST_DELEGATE(fOnAttributeModified) does not compile

Hello everyone,

when i add the line
to my header file it will not compile stating fOnAttributeModified is undefined.

#pragma once

#include "Engine/DataTable.h"
#include "Engine.h"
//#include "MyPlayerState.h"
#include "Runtime/CoreUObject/Public/UObject/ConstructorHelpers.h"
#include "MyAttributes.generated.h"


When i remove the delegate macro it compiles without issue.


EDIT: Some addition information, what I’m trying to do is make it so that when an attribute is modified connected functions will trigger.

So i’ll make an instance of the FOnAttributeModified OnAttributeModifed; and then in the constructor:
OnAttributeModified.AddDynamic(this, &UpdateAttributeData);

Then in any function which changes the attributes i would add OnAttributeModified.Broadcast;

Ideally i would be able to use this outside of the class for other classes that have the attributes object. For instance lets say in the player state there is an UMyAttributes *MyAttributes; and that HP is related to the attributes but is part of the player state. so in the constructor i would have something like:

MyAttributes->FOnAttributeModified.AddDynamic(this, &UpdateHP); where UpdateHP() is some function in the player state class. This way whenever an attribute is changed it will update my HP.

You still have to declare a fOnAttributeModified. For example like this:

fOnAttributeModified OnAttributeModifiedt;

The f has to be a capital F in fOnAttributeModified.

Normally you wouldn’t prefix the Delegate Type with “On” but name the actual Delegate “On”


     FAttributeModified OnAttributeModified;

I see thank you!