Blueprint isn't called from C++ method

My problem is I want to recive a key input in C++ and notify via event the blueprint about it. for that I read so far, BlueprintimplementableEvent is the way to go. I implemented it and it even shows up in the Blueprint I want to recive the event in:

This is the way I declare the methods in my Class refference:

//Trigger to show the menu.
UFUNCTION(BlueprintImplementableEvent, Category = "UMG Game")
void ShowMenu();
//Trigger to hide the menu.
UFUNCTION(BlueprintImplementableEvent, Category = "UMG Game")
void HideMenu();

And this is where I call them in my c++ code:

void AMyPawn::MenuKeyHit()
	if (bMenuShown == true)
		bMenuShown = false;

    bMenuShown = true;

I even debugged it, and HideMenu() and ShowMenu() are invoked as expected when the targeted key is hit.But the blueprint doesn’t seem to get the event. for simplicity I just added an QuitGame node, what also actually doesn’t happen.

Also the Blueprint breakpoints doesn’t get hit when debugging the blueprint.
What may be the cause for this behaving?


Adding screenshot that I hope provides all information about MyPawn’s object “test”'s implementation and inheritance hierachy.


Ok, what I figured out so far (thanks to @Ruba1987) I had an object of MyPawn, not of test itself in the level.
Now I removed the MyPawn object and placed a test isntance. NOW the the MenuKeyHit() event doesn’t notice the keyinput event anymore. But it feels like going in the right correction. any further idea?

Could be a subclass/parenting issue. If you have a subclass make sure you call the parent function or it won’t bubble up.

That’s just a shot in the dark though. Your code here doesn’t look complete. You don’t actually call MenuKeyHit() anywhere in the code you have posted. Can you post some more complete screen shots/code so we can see the big picture?

I think Zaibis means to trigger a blueprint from an event in C++.

Player pressed a key. Event in C++ is triggered and should call a blueprint.

Well I can post it if it helps. but as I allready told within the OP: MenuKeyHit is bind to the keyinput (“Q” in my case via Action mapping). and I debugged the c++ code and can say MenuKeyHit() is called exactly in the way I’m expecting it. But what is meant by subclassing? to clarify, what I’m actually doing: I’m actually runnign through this tutorial: But Instead of displaying the menu all the time, I’m trying to change the Game mode depending on the input collect by an subclass of Pawn. Since the UMGGame class is able to display the method events of MyPawn class within the blueprint I expected it to being able to detect them aswell. So what specially you need to see further to follow up my problem? And could this indead by a subclassing problem? if so, how to fix it?

What is the parent of your Test blueprint and does Test have a child that you are actually spawning into the world? I would imagine that Test is a direct child of whatever your c++ class name is but I’m not sure.

Might sound silly but it could also be that when you’re debugging you don’t have the correct instance set for debug. When you’re running make sure that at the top of the blueprint in the toolbar it had the instance name rather than “no debug object selected”. If you’re setting break points this shouldn’t matter though.

Also might be easier to test with print strings but that’s just preference.

I added a screenshot that I hope is able to provide all neccessary informatiosn about its implementation.And I had no instance to select at all. and yeah because I was not trusting my blueprint debug skills is also why I directed the ShowMenu event to QuitGame, so that I for sure will notice it. But not even that happened. So probably I implemented in kind of wrong way. would be great If you now know what I’m doing wrong.

I’m finally pretty close to the solution!!! I figgured out that when I’m marking text while PIE and then pressing Posses button it is working as expected! So probably I just forget to set some option some where. Any clou?

Maybe try setting the default controller and pawn classes in your GameMode? It would be in the WorldSettings window.

Hm, nope that is allready set as those.

Based on your edit above you are placing it in the level? That’s not right. You shouldn’t be placing your pawn that you play as in the level. That should be the pawn that you spawn as, therefore there is no need to place one in the level. What type of character do you spawn as?

Typically if you are playing as a specific pawn that pawn is actually a Character which is a subclass of Pawn. Not necessary but something you might want to consider.

Well I don’t know what I’m spawning as. I don’t even know how/where to check/set that. BUT it seems like thats the solution, since all works fine as soon I “posses” the pawn, what is probably setting the game into a state that would be same as spawning as that pawn. So that sounds like the solution would be to figgure out how to do that.

It is set. I jsut figgured out, when I press launch isntead of play all is working as expected aswell. May it be that by pressing play the player isn’t actually the real player and jsut becomes the player he would be in launch, if he presses posses in Play?

are you playing or simulating?

most time I’m playing. but there isnt any difference for this problem in simulation or play. What is the generell difference between it?