BlueprintNativeEvent BluePrint not firing

Hello,

I have the following declared in a blueprint class:

UFUNCTION(BlueprintNativeEvent, Category = "PK_Login_Presenter")
		void OnConnectFail();
		virtual void OnConnectFail_Implementation();

cpp:

void ALoginPresenter::OnConnectFail_Implementation()
{
	GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::, TEXT("ConSrvFailC++"));
}

And the blueprint:


However, when I call the OnConnectFail function like

Presenter->OnConnectFail();

I get the C++ implementation:


I’m pretty new, so can someone please explain what I’m doing wrong? I’m trying to get the blueprint Print Text to be called. Thanks.

Hi ES-StuBedore,

I don’t have any issue with any of this using a variable to call the function but once I attempt to call it using a pointer as you did, things start going wrong. Can you give me context as to how you’re creating the pointer (Presenter) that is calling the function? Also, what class are you using as the parent class for the class for ALoginPresenter? This information should help me pin down the issue.

Hey ,

The parent class is AActor, and I’m using the following to get the pointer:

for (TActorIterator<ALoginPresenter> ActorItr(GetWorld()); ActorItr; ++ActorItr)
	{
		Presenter = *ActorItr;
	}

There’s only one Presenter in the game.

I apologize for the back-and-forth like this but would it be possible for you to provide me with the actual code files themselves? I still don’t have enough context to reproduce the issue you’re having exactly. I either have it work perfectly, or run into some other issue.

I copied your code files directly into a new project and everything seems to be working fine. The only thing I did (Seeing as I don’t have your blueprints) was to make a blueprint of the ALoginPresenter class and place the Event On Connect Fail node and Print Text node in your picture above. I also placed the function call Presenter->OnConnectFail(); in StartPlay(); to call it immediately to avoid any possibility of the DoLogin function posing problems. When I did this, I received the output for the Print Text but not the output from OnConnectFail(); which is expected. If you do want both, you can add a ‘Call to parent function’ node between those two nodes.

Is the blueprint that you’re placing these nodes in of the ALoginPresenter class? If not, please try that to see if it’ll work. Also for simplicity’s sake, please try moving the Presenter->OnConnectFail(); function to StartPlay(); to make sure nothing interferes.

Thanks for the reply. I just deleted the class from disk, deleted the blueprint and restarted the editor/VS and readded everything…and it works now. So I guess there was no error afterall, just an engine hickup? Anyways, thanks again.

Thanks for the reply. I just deleted everything from disk/editor/vs that had to do with this issue, and readded everything and it works now. I guess it was just some editor hickup or something.

Anyways, thanks again for the help.