Connecting an Array of BlueprintType to Array of BlueprintInterfaceType results in an empty array

Reproduction Steps:

1 - Create a blueprint interface (BlueprintInterfaceType)

2 - Create a blueprint implementing that interface (BlueprintType)

3 - Create an array of BlueprintTypes

4 - Create a Blueprint Library with a function that takes an array of BlueprintInterfaceTypes as input

5 - Do something with that array inside said function

6 - Call the library function feeding it an array of BlueprintTypes

At this point UE will crash. If you manually create an array of BlueprintInterfaceTypes, cast each element from array of BlueprintTypes and add it to the BlueprintInterfaceTypes array, it will work just fine. If you put a breakpoint on a function call node, you can see that the BlueprintInterfaceType array is empty, even if the array feeding it is not.

Hey ,

I am having a little trouble reproducing the issue. If you can give me a little more information/steps and add some images of your blueprint setup, that’d help a lot.

Sincerely,

I have since abandoned the approach for less elegant solution that works so no such images exist anymore, but the purpose of a collection was to allow me to return a single element from a collection based on random weight.
Interface (IRandomWeight) had one function, GetWeightedRandom(), and the implementation simply returned a float variable representing the random weight for a particular instance of the blueprint.
So, i have a blueprint (ContainerBP) that has an Array of Actor Blueprints (lets call them SampleActor), which implement the IRandomWeight, and a Blueprint Library Function, GetWeightedRandomElement(), which takes an Array of IRandomWeight as input, calls GetWeightedRandom() on each element, sums them up, makes a random roll, and then selects the element and returns it via the output node (as single IRandomWeight object)…
When i call the GetWeightedRandom Element() library function, i provide the “original” Array of SampleActors directly into its Array of IRandomWeight, and blueprint does not mind that one bit. However, if i put a breakpoint on GetWeightedRandomElement() call, and check the arrays - Array of SampleActors will show first 10 elements in it when i hover over the output of the node, but the Array of IRandomWeight will appear to be empty. If i first take my time to create a IRandomWeight array inside the ContainerBP, cast each element of Array of SampleActors into IRandomWeight and add it to that array, and provide it as a library function input, the thing works, but its a very ugly solution.

I have since abandoned the approach for less elegant solution that works so no such images exist anymore, but the purpose of a collection was to allow me to return a single element from a collection based on random weight.
Interface (IRandomWeight) had one function, GetWeightedRandom(), and the implementation simply returned a float variable representing the random weight for a particular instance of the blueprint.
So, i have a blueprint (ContainerBP) that has an Array of Actor Blueprints (lets call them SampleActor), which implement the IRandomWeight, and a Blueprint Library Function, GetWeightedRandomElement(), which takes an Array of IRandomWeight as input, calls GetWeightedRandom() on each element, sums them up, makes a random roll, and then selects the element and returns it via the output node (as single IRandomWeight object)…
When i call the GetWeightedRandom Element() library function, i provide the “original” Array of SampleActors directly into its Array of IRandomWeight, and blueprint does not mind that one bit. However, if i put a breakpoint on GetWeightedRandomElement() call, and check the arrays - Array of SampleActors will show first 10 elements in it when i hover over the output of the node, but the Array of IRandomWeight will appear to be empty. If i first take my time to create a IRandomWeight array inside the ContainerBP, cast each element of Array of SampleActors into IRandomWeight and add it to that array, and provide it as a library function input, the thing works, but its a very ugly solution.

Hey,

Since you found a workaround, we are resolving this post for tracking purposes. If you can provide any additional information on the original bug, please feel free to add a comment on this to reopen the post.

We’ll be on the lookout for similar issues.

Sincerely,

The workaround is enough work that it beats the purpose of using the Interface in the first place, much simpler to implement the GetWeighterRandomElement() locally and forget the Blueprint Interface.
Function input should be able to treat an Array of SampleActors as an Array of IRandomWeight without trying to explicitly upcast it, which i suspect its doing and failing at it. In any case, i do not require any further assistance on this issue.