TArrays Help

Maybe I’m not understanding TArrays or I am missing something.

I created an array UPROPERTY(EditAnywhere)TArray ARArray; I have 3 child blueprints of ABaseAutoWeapon I want to populate the array with.
When I go into the editor there is nothing to select from. I tried with AActor and only have a few scene elements. The only way I could get a list to pick from would be if I made a TArray of type UObject.

What am I missing/doing wrong.

I had the same issue, for some reason, TArray does not take Derived Classes into account and only the base class passed into the TArray as a parameter.

I used
TArray<TSubclassOf<BaseClass>> DerivedArray;

UPROPERTY(EditAnywhere, Category = "Weaponry")
Using TArray<TSubclassOf<ABaseAutoWeapons>> WeaponArray;

would give you your required input I think.

This let me see all the derived classes as well. I encountered another hurdle after this, which is where I am stuck where I need to cast the TSubclassOf object in the array and get a derived class member whose method I need to access.

TLDR : My method works well if you jsut need to spawn the derived class instances. If you need to run some virtual method in the derived class, there are some issues.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms