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 :
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
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
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
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…
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
I known my blueprint was terrible to checking
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 )
Thank you so much bro
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
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 (?)