Is not valid (pending kill or garbage)?

I am not sure how to easily explain this, so I’ll give a short then long explanation.

Short: In the print text nodes at the end of all the loops, I’m getting 9 for the length of the Planets Sorted array, but only 1 of those 9 have a non-zero distance and the rest give the errors.

Long: I am trying to remove actors that have similar distances (planets in a solar system). The Sorted Planets array is sorted by absolute value distance from 0,0,0. If I remove any of the Is Valid nodes, I get the errors shown. It does seem to be kind of working. I start with 18 planets (I verified there are still 18 after sorting) and it drops them down to 9. However, of those 9, only 1 seems to be a valid object. Additionally, it doesn’t matter what I set the value for in the “less than” check, I always get 9. 9 planets are showing in the viewport (PIE). Before I tried using the Is Valid nodes, I added the Removed Planet variable and started the For Loops over again if it is true. That did not fix the problem.

It seems very inconsistent between what is visible, what is in the Planets Sorted array, and what is an actually valid object. Because of this, I’m having a hard time figuring out what the actual problem is. Combine that with the fact that the Less Than check seems irrelevant and the confusion goes beyond insane.

Can someone lend a hand please? Maybe another set of eyes can see what I cannot.

Your blueprint looks fine for the most part. Although you shouldn’t modify an array that’s used in a for each loop, you exit both loops right away so there should be no harm there. The only minor thing I’m seeing is the ABS node should be after the subtract node when you take the difference in distances.

I could be wrong, but everything you’re describing is indicating that your PlanetsSorted array has duplicates in it. Verify that there are no duplicates first to eliminate that possibility and then we can look at other causes.

2 Likes

Thank you! For some reason, my sorting was making duplicates of some of what it was sorting, and wasn’t sorting correctly at all. I had verrified that the number after sorting was correct, but didnt actually check the content of it. Lesson learned!

After fixing the sorting (and verifying it) and adding the ABS you suggested for good measure, It works exactly as expected now.

I’m starting to notice the biggest issue with UE is duplication. It seems like almost every problem I have had has come down to some kind of duplicate problem.

Thanks again!

1 Like