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 can't I use an array in my function declaration?

I'm trying to write an event in C++ I can hook into in blueprint, so my C++ code can queue up dialogue and my blueprint HUD display it. Doing this with a single instance of my struct works perfectly:

 struct FDialogueLine {
         UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Speech")
         FString line;
         UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Speech")
         FName speaker;
     UFUNCTION(Category = "Speech", BlueprintImplementableEvent)
     void DisplayDialogue(FDialogueLine dialogueLine);

However, if I try to alter the function dec to accept multiple lines of dialogue in a single call, the compiler throws an error, "'void AHUDManager::DisplayDialogue(const TArray &)': overloaded member function not found in 'AHUDManager'":

 UFUNCTION(Category = "Speech", BlueprintImplementableEvent)
     void DisplayDialogue(TArray<FDialogueLine> dialogueLine);

That error sounds to me like it thinks I'm overriding an existing function, but AHUDManager inherits directly from AActor, so I know there isn't some kind of weird namespace clash. I don't provide a function definition (since the point is to write an event that blueprint can hook into), and there's nothing named DisplayDialogue elsewhere in my project, so is there an obvious reason why this would be failing?

Product Version: UE 4.11
more ▼

asked Apr 21 '16 at 08:31 AM in C++ Programming

avatar image

276 97 67 84

avatar image HInoue Apr 21 '16 at 10:03 AM

After looking for similiar problems I adapted my syntax based on https://answers.unrealengine.com/questions/95396/fail-to-pass-tarray-from-c-to-blueprint.html , and found that the array works fine if I declare it like this:

 UFUNCTION(Category = "Speech", BlueprintImplementableEvent)
 void DisplayDialogue(const TArray<FDialogueLine>& dialogueLine);

I don't know why it works, but it seems to :)

(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