x

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"

Why does triggering character events from c++ work but not widgets?

I went through the small tutorial Rama posted on calling blueprint events from c++. I used my character class to test it out and had the blueprint event print to screen, thus verifying the vent was called. However when I try to do the exact same thing with an extended user widget class the event does not fire.

My setup is something like this...

 UFUNCTION(BlueprintImplementableEvent, Category = "KORE WIDGET")
 void myExtendUserWidget_CallEvent();
 
 myextendCharClass::SendMessage()
 {
 UKoreWidget* myCustomWidget;
 myCustomWidget = CreateWidget<UKoreWidget>(GetWorld(), UKoreWidget::StaticClass());
 myCustomWidget->myExtendUserWidget_CallEvent();
 }

In the blue print I just pull a print off the event to check it same as I did with the character event. However it does not fire. Any ideas?

Product Version: UE 4.14
Tags:
more ▼

asked Jan 18 '17 at 10:59 PM in C++ Programming

avatar image

Thumper
966 143 150 390

avatar image Thumper Jan 19 '17 at 01:56 PM

Yeah so I worked on this all day yesterday and no love. I'm really confused because it works when I call an event on my character class from code within my character class. Is there some limitation where you can't call an event from outside the owning objects class?

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

1 answer: sort voted first

Because this

  myCustomWidget = CreateWidget<UKoreWidget>(GetWorld(), UKoreWidget::StaticClass());

creates raw UKoreWidget class object, not the class object made out of blueprint which overrides myExtendUserWidget_CallEvent function which prints the text. Create the widget in blueprint insted, or somehow get UClass of that blueprint and use it CreateWidget insted UKoreWidget::StaticClass().

Remeber blueprint is class same as C++ class

more ▼

answered Jan 19 '17 at 02:03 PM

avatar image

Shadowriver
37.2k 936 172 1116

avatar image Thumper Jan 19 '17 at 03:51 PM

Any idea how I could get the blueprint version from code, to use to create?

avatar image Schadek Jan 19 '17 at 04:44 PM

Put this in your character class header: UPROPERTY(EditAnywhere, Category = "Widget") TSubclassOf KoreWidgetClass;

Now you can set the right class in your character blueprint and use it in your code instead of UKoreWidget::StaticClass().

avatar image Thumper Jan 19 '17 at 04:53 PM

Okay, so you were correct. The problem was that I was using the staticClass of the UKoreWidget instead of an actual reference.

UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "KORE WIDGET") TSubclassOf WidgetTemplate;

The above provides a slot available in the details panel in the editor for the class the member is on (in my case I put this variable in my character class). There you can add the reference to the correct BP by selecting it. So instead of using the static class like I did at first, use the WidgetTemplate reference that is populated in the editor.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
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