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"

TArray = type must be a UCLASS, USTRUCT or UENUM-

Hello, I've got a blueprinttype struct with various UProperty data in it. Then on the Enemy class I have:

 UPROPERTY(EditAnywhere) TArray<struct FEnemyAttack> Attacks;

It's worked perfectly up until upgrading to 4,17. Now it gives the following error:

 StateError Unrecognized type 'FEnemyAttack' - type must be a UCLASS, USTRUCT or UENUM

I've tried including the struct header to this Enemy.h, and including it to the main Project.h. I can't figure out how to get this working again.

Any suggestions?

Product Version: UE 4.17
Tags:
more ▼

asked Sep 27 '17 at 10:00 PM in C++ Programming

avatar image

Juice-Tin
106 24 21 28

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

1 answer: sort voted first

Inside your header file, try to declare your struct then use it in a TArray like this

 USTRUCT(BlueprintType)
 
 struct FTestStruct
 {
 
 GENERATED_USTRUCT_BODY()
 
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "TestStruct")
         FString strValue;
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "TestStruct")
         FTransform transformValue;
     UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "SaveLoadData")
         float floatValue;
 };
 
 TArray <FTestStruct>  testStructArray;

Note that you should leave no space inside angle brackets. You got this error becasue if i remember it right, new version demand that if you use a function that exposed to blueprint, enum have to be exposed to blueprint as well.

more ▼

answered Sep 28 '17 at 03:35 AM

avatar image

CKong
674 24 15 46

avatar image Juice-Tin Sep 28 '17 at 02:53 PM

It is already exposed to blueprint though. Edit: I found out the real problem... There was an include-loop, causing that incorrect error report

My class with most of the structs "CustomStructs.h" has a a parameter somewhere like this:

     UPROPERTY(EditAnywhere, Category = "AKQ_Interaction") TMap<TSubclassOf<class AEnemy>, int32> EnemySpawns;
 

All of a sudden UE4 is saying that AEnemy is undefined. So because of that I included Enemy.h at the top. I figured there was some sort of loop going on, since my Structs.h was including Enemy.h, and my Enemy.h was now including my Structs.h

I moved the whole struct that needed to include Enemy.h into another file, which broke the loop, and made everything work!

Although there was a different solution, thanks for the answer. I'll mark it as correct as it may be a valid answer for someone else with a similar problem.

(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