Adding a function call to a delegate not working

Trying to wrap my head around this delegate stuff, and I have to say it’s rather confusing. I am trying to copy the functionality from the Multiplayer shootout in C++.

I have my own player controller defined, and within there I am defining a delegate.

Infantry_RebornPlayerController.h:

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
#pragma once
#include "GameFramework/PlayerController.h"
#include "Infantry_RebornPlayerController.generated.h"

DECLARE_DYNAMIC_MULTICAST_DELEGATE(FClientPostLoginDelegate);

UCLASS()
class AInfantry_RebornPlayerController : public APlayerController
{
	GENERATED_BODY()

public:
	AInfantry_RebornPlayerController();
	
	UPROPERTY(BlueprintAssignable)
		FClientPostLoginDelegate ClientPostLogin;

protected:
	void RotateToMouseCursor(float DeltaTime);

	// Begin PlayerController interface
	virtual void PlayerTick(float DeltaTime) override;
	// End PlayerController interface

	/* Player movement */
	float yawSpeed = 5.0f;
	void OnClientPostLogin();
};

Infantry_RebornPlayerController.cpp:

// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.

#include "Infantry_Reborn.h"
#include "Infantry_RebornPlayerController.h"

AInfantry_RebornPlayerController::AInfantry_RebornPlayerController()
{
	bShowMouseCursor = true;
	bEnableClickEvents = true;
	bEnableMouseOverEvents = true;

	ClientPostLogin.Add(&AInfantry_RebornPlayerController::OnClientPostLogin);
}

void AInfantry_RebornPlayerController::PlayerTick(float DeltaTime)
{
	Super::PlayerTick(DeltaTime);

	this->RotateToMouseCursor(DeltaTime);
}

void AInfantry_RebornPlayerController::RotateToMouseCursor(float DeltaTime) {
	FHitResult Hit;
	GetHitResultUnderCursor(ECC_Visibility, false, Hit);

	if (Hit.Actor != nullptr) {

		// Get local reference to the controller's character and its rotation
		ACharacter *currentChar = this->GetCharacter();

		if (currentChar != NULL) {

			FRotator charRotation = currentChar->GetActorRotation();

			// Get the rotation of the mouse direction
			FVector TargetVector = Hit.ImpactPoint - currentChar->GetActorLocation();
			TargetVector.Normalize();

			FRotator targetRot = FRotator(charRotation.Pitch, TargetVector.Rotation().Yaw, charRotation.Roll);
			FRotator newRot = FMath::RInterpTo(this->GetControlRotation(), targetRot, DeltaTime, this->yawSpeed);

			// Since I only want to turn the character relative to the ground, 
			// the Yaw is the only change needed.


			this->ControlRotation = newRot;
			currentChar->SetActorRotation(newRot);
		}
	}
}

void AInfantry_RebornPlayerController::OnClientPostLogin()
{
	this->SetupInGameUI();

}

But when I compile I get:

Error 1 error C2664: ‘void TMulticastScriptDelegate::Add(const TScriptDelegate &)’ : cannot convert argument 1 from ‘void (__cdecl AInfantry_RebornPlayerController::* )(void)’ to ‘const TScriptDelegate &’ C:\Users\Documents\Unreal Projects\Infantry_Reborn\Source\Infantry_Reborn\Infantry_RebornPlayerController.cpp 12 1 Infantry_Reborn

I have read several sources online that just don’t match up with what is currently in the engine (Bind does not exist, AddDynamic does not exist, the only one I see is Add and it doesn’t work for me).

It should be:

ClientPostLogin.AddDynamic(this,&AInfantry_RebornPlayerController::OnClientPostLogin);

first argument is object that function will be called on. Also binded function should be visible to reflection system, so put empty UFUNCTION() before binded function.

UFUNCTION()
void OnClientPostLogin();

Not entirely sure why but AddDynamic doesn’t exist for me, yet there seem to be lots of references to it. Perhaps something that was changed in 4.8?

No, i still use them and they work in 4.9, try to build regardless of what Intellisence tells you. I actully remeber i had similar issue in the past but dont remeber how i fixed that

Computer is in shambles at the moment lol so will try again tonight but I’m fairly certain I did try building and it still gave me an error. I may have been calling it wrong, though.