Inside an actor, I want to have a “for each loop” that creates a collision sphere for each item in the loop.
Checks if the sphere is overlapping a different sphere and if so delete and try again.
The goal is to have a number of collision spheres that do not overlap.
Blueprint Runtime Error: “Accessed None trying to read property CallFunc_Array_Get_Item”. Node: Branch Graph: UnitMove Function: Unit Move Blueprint: BP_UnitController
And
Blueprint Runtime Error: “Attempted to access NODE_AddSphereComponent-0_181 via property CallFunc_Array_Get_Item, but NODE_AddSphereComponent-0_181 is not valid (pending kill or garbage)”. Node: Branch Graph: UnitMove Function: Unit Move Blueprint: BP_UnitController
There’s something very ‘whacky’ going on in that code, to do with the loops, but the main way to avoid overlapping objects, is to keep an array of the positions used, and run through it each time checking for nearby objects.
Just write a function to check if the point you’re about to use is near one you’ve already used. Then, you can just consult it before placing one.
Thank you, it works very well. Added a clear Current Locations to the beginning and I’m now trying to figure out how to avoid an infinite loop if the overlaped positions don’t have space to be created.
With the changes outlined in red I got no infinite loop problems even if the spheres don’t fit in to the radius of the “GetRandomPointInNavigableRadius”