Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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:

CurrentEventgraph containing the events

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.

How MyPawn is implemented


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?

Product Version: UE 4.10
more ▼

asked Dec 13 '15 at 04:53 PM in C++ Programming

avatar image

23 3 6

avatar image RuBa1987 Dec 13 '15 at 05:41 PM

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?

avatar image KAISERslin Dec 13 '15 at 05:51 PM

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

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

avatar image Zaibis Dec 13 '15 at 08:54 PM

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: https://docs.unrealengine.com/latest/INT/Programming/Tutorials/UMG/4/index.html 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?

avatar image RuBa1987 Dec 14 '15 at 11:59 AM

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.

avatar image Zaibis Dec 14 '15 at 05:11 PM

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.

avatar image Zaibis Dec 14 '15 at 06:36 PM

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?

avatar image RuBa1987 Dec 14 '15 at 06:46 PM

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

avatar image Zaibis Dec 14 '15 at 07:28 PM

Hm, nope that is allready set as those.

avatar image RuBa1987 Dec 14 '15 at 07:36 PM

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.

avatar image Zaibis Dec 15 '15 at 01:19 PM

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.

avatar image Zaibis Dec 15 '15 at 06:17 PM

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?

avatar image RuBa1987 Dec 15 '15 at 06:39 PM

are you playing or simulating?

avatar image Zaibis Dec 17 '15 at 05:14 PM

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

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

0 answers: sort voted first
Be the first one to answer this question
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question