Is this a bug of looping node or i wrong somewhere ??

i have one blueprint simple like this :


My array vector have 8 elements, i used looping node to spawning 8 actors by SpawnActor node.
But sometime it’s spawning only 7 actors so it’s have bug here like this :

and as my blueprint, it’s start infinite looping.
Is that a bug or i did something wrong in this logic ??

Thanks for reading, sirs.
Help me please. :pray: :pray: :pray:

p/s : i tried another way with For Each Loop and got same problem, so i guess have something i didn’t known about this ??

1 Like

Nothing is calling the loop here, so it’s not running. Are you getting the error from somewhere else?

Also, you can use ‘lastindex’ instead of ‘length’-1

Or ‘foreach’, would be an easier way :slight_smile:

1 Like

Thanks for help bro :pray: i didn’t known have that node :smiling_face_with_three_hearts:
yah, it’s a bit hard to see for all my blueprint, so i hope you can see some main nodes i used there


i used " For Each Loop" node by other way, but it got same problem when it running good few times and suddenly have time it can not spawning, i used something to check it again then i saw it have less than 1 vector point ( input For Each Loop array have 8, after that it showing only 7 vector points to spawn )


You can see other way i used with For Each Loop here
It’s hard to follow, i’m so sorry about that :pray:
i used length of array spawned and length of input vector to checking While loop, but becuz it’s giving out only 7/8 vector points input so it’s became infinite loop. I wonder how can be that ???

Calling the for loop ( whatever kind ) in a while loop is probably causing the problem, actually.

I’ve been using the engine for years now, and the only time I’ve ever used a while loop, is when I didn’t really know what I was doing. I know it sounds a bit nuts, but you really never need a while loop :slight_smile:

What are you checking in the while bool?

1 Like

image
because after logic in loop have new actor spawn on each vector in Input Vectors array
then those actor will be get add in Actor Spawned array.
So as i think length of Actor Spawned array growing up, if its length = length of Input Vectors array so that’s mean all vectors in Input Vectors array have actor spawned on them.
So while [ Length of Actor Spawned < Length of Input Vectors ] logic inside looping should keep going till [ Length of Actor Spawned = Length of Input Vectors ] then it’s completed and going out loop.
p/s : i change While Loop by Branch, it’s looking same

1 Like


This’s explain about this error ( same error when i’m using For Each Loop node )

:dizzy_face: how can this happen ??

I think something else is going wrong here.

If you have a for loop and spawn 8 objects, they spawn. That’s it, you don’t have to check they spawned.

Unless something is stopping them spawning, in which case you can just change this to ‘always spawn’

image

1 Like

Thanks for suggest bro, but i can’t do that, that collision check to stop 2 actors spawning on same vector like this :
image
I was using this blueprint to make sure actors will not spawning closed together, but it’s fail too :dizzy_face: so bad for me :face_with_thermometer:

Ok, but then how can they all spawn? Are you randomizing the locations within a certain area?

You can use a function to check if what you are about to spawn is too close, and get another location. I can show you that, but I need to know how you are choosing the points…

1 Like

i giving input array vectors, those vectors made sure can not closed together ( to make sure actors spawning will not get overlap ).
Then i let actors spawning on those vectors.
I print number of vector before put in For Loop or For Each Loop node ( which always show me right number = 8 ).
And i used Draw debug sphere to see all vectors

same time like that i used Print node to print length of vectors array ( that always be 8 )

Maybe as you said, number vectors input was wrong because Draw Bug Sphere node showing vectors in array before put in that function. But, Print node showing number vectors always = 8, how can Draw Debug Sphere node showing 7 sphere sometime ???

This’s how did i making function generating those vectors, i’m so sorry cuz it’s hard to following :pray: :pray: :pray:



:face_with_thermometer: i thought i passed function generating those vectors, now i gunna checking it again :face_with_head_bandage: :face_with_head_bandage: :face_with_head_bandage:

If you only run the loop code, it will only use the correct array items, it’s impossible to run off the end of an array with a foreach loop.

It’s something you’re doing in your other code.

Sorry, but it’s quite messy code, I can’t really see anything :joy:

1 Like

I known my blueprint was terrible to checking :dizzy_face:
This’s last check of my code, it should stop my function generating wrong vectors to add into array.
Can you see something wrong i did here ?
This blueprint make sure 2 bool :
1, it’s 2 difference vector checking
2, distance between vectors in array can not < Min distance
( if have any 2 vectors has distance < Min distance so Clear array Vectors and looping back to begin generating vectors )


Thanh you so much for helped bro :pray: :pray: :pray:
P/s : What you mean about “impossible to run off the end of an array with a foreach loop” ? I don’t get this mean ?

I have written code to check if two vectors are too near each other, many times. You can do it with one loop :slight_smile:

Your description is more useful, actually. Presumably you are generating random points. Are they in a box, in a plane, in…?

I will drop a function to check new points in here soon.

1 Like

No, all vectors random in space, they’re not have any limits as box or plane

Ok, this is how to check if a new point is too close to other points

Then, you use that function like this

See, it keeps checking the new point until it’s ok, then moves on. This will give me 8 locations, and keep trying if any are too close to each other.

( I still don’t get how you’re making your new points, so don’t copy that bit )

1 Like

Thank you so much bro :pray: :pray: :pray: :smiling_face_with_three_hearts: :smiling_face_with_three_hearts: :smiling_face_with_three_hearts:
I’ll try to apply it into my blueprint
I was wonder how to tick those vector as bool used but don’t known how to do it.
Yours’s easy to understanding much more than my silly blueprint :pray:

1 Like

This array holds the ones you’ve used

image

1 Like

Yep, i got your way with bool used.
And as you said, my problem i gave at first was wrong, my input vectors array was wrong so it made problem.
Now i’m checking a gain my messy function before to known why sometime it generating 7 vectors or 8 vectors with 2 vectors in same place ???
Cuz it’s printed number vectors generated are 8, but Draw debug only 7 location (?)


image