Problem with array of objects

hey everyone,

The problem I think I have ran into is that Objects are not being added correctly to my array. I have an array of ‘Weapon’ Objects, and in the ‘Event On Begin’ I have added 2 objects using ‘Add’, I have added a ‘RifleBlueprint’ object and a ‘PistolBlueprint’ object, both are children are the ‘Weapon’ blueprint class. I have no issues doing this and the game can run, however when I find the size of the weapon array, it is of size 2 (which is what I want), and if I check if the array contains either the pistol or the rifle, it returns true (which is what I want), but if I try to find the index in which these items are located, they are both at index 0, and I am unable to cast them to their correct types when trying to take them out of the array with a ForEach loop.

Please help! :slight_smile:

Add print node to “Cast to” fail. And print that it failed.
Are you sure you have valid references to those actors in variables, ie that they do not have “nil” instead of any data?

Instead of adding try set your array of weapons directly. Either in defaults tab, or make array out of variables you have.
Then you can be sure they are in array.

Yeah I have done that, the cast fails every time, but I have no idea why it fails.
I have tried getting the items and using ‘Make Array’ method with the same problem occurring. I am also unable to add Items into the array directly, when I try to search for an asset to assign, I always get 0 search results, no matter what I search, I have also had no luck when using the ‘use selected object from the content browser’.
I am not too sure what you mean by ‘valid references’, but if it means anything, when I grab the Array Element from the ForEach loop and try to use tostring(Object), I get ‘None’.

Here is a picture of the details when the Weapon array is selected to better help explain what I was trying to say in my previous message :slight_smile: