Adding Delegate to OnClicked

Hi

I am trying to add a function to OnClicked inside class constructor. Here is my code:

AChessPiece::AChessPiece()
{
        ...
        ...

        AddDynamic(OnClicked, &AChessPiece::PlayerClickedPiece);
}

The error it gives me is: ChessPiece.cpp(21): error C3861: ‘__Internal_AddDynamic’: identifier not found

I have looked at other answerhub questions, but stuck. How can i do it?

Seriously, how dumb i am? Maybe i should get some rest.

It should be like this

OnClicked.AddDynamic(this, &AChessPiece::PlayerClickedPiece);

Just a note: The callback (in this case AChessPiece::PlayerClickedPiece) must be marked with UFUNCTION() in order for this to work. Otherwise it’ll silently.

I have been trying to make it work but did not know that necessity of that macro. I could not figure it out until see your comment. Thank you sir! Thank you so much :slight_smile: