Let me start by saying i think the problem is here
i noticed the for loop runs complete more often than it ought to so i added the check to see if it has gone through the whole array
So what’s supposed to happen is we spawn a room, around that room ( just forward atm ) we see if theres a room there… if there is get the actors of room again… and run the check if theres already a room in which case don’t make a room, move on to the next room and check if theres already a room in front of it… repeat up to Max rooms
simple version, should make 10 rooms in a row spawning each off the last ones location if it’s not already a taken location
Works just fine when we only use forward vector like pictured above
But as soon as we allow it to consider another dimension
in this case right
Seeing a few things that aren’t right or could make a next issue.
When you compare a vector containing float components (X, Y, Z) it could be that === returns “not equal” for vectors that look equal to the eye. That’s a float precision problem and the reason why nodes like “is nearly equal” exist for floats and vectors.
That loop comparing array index to length of the same array can never be true, because we start counting indexes at 0. an array with length 10 would have max index 9. Blueprints for some reason also accepts a function with one path without return value.
Once you position a room of X size at a center location, you currently check if that center location is taken but you don’t mention the space the room actually takes. One room could overlap another still.
I feel like you should look at existing partitioning patterns first and see if any fits your need, so you avoid overcomplicating all these checks. With a partitioning algorithms you cut up available space into rooms, instead of the other way around. There are many, but take a look at Binary Space partitioning just to get the idea. 0:35 / 10:15 Binary Space Partitioning Algorithm - P13 - Unity Procedural Generation of a 2D Dungeon
it does almost exactly what i want it to do… currently the spacing is 150 which is bigger than the block size of 100 but thats to see whats going on
the block closest to the pov is “self” every other cube is “room” however some of them get placed at the same spot beacuse of the data being wrong somewhere
somehow it’s passing every check ive tried to make and still spawns it inside the other one…
i don’t know how this is possible as its supposed to run through the location of each one and if its the same Not add it… but it adds it anyway which should be impossible?
recolored main to orange to make it easier to see
heres 10 rooms in white… but theve come all stacked in this run
The data at [1] and [2] are duplicates [4] somehow when it does the check where its supposed to compare the place it’s about to spawn one to the places its already spawned one it skips that check or something which should be impossible and adds it to the array of existing locations
Tis why i say the problem is probably the 1st image of my post
Found another issue that is messing with our minds. See the green nodes? They are called Blueprint Pure nodes. Every time you access a value from them they execute again (not just once!). Only the blue nodes execute once.
Your nodes are executing the random generator multiple times, once for the test then twice after the test. Create a local variable to copy its output to, then use the local variable to read the value from.
i mean i see where your at but the vectors in question are the same and should never be let through the branch statement to be added to the array “spawned Rooms”
ill give that a try in case i am just missing something but it should be getting the forward or right vector of each room and seeing if its already made something there
If location to check matches anything in “SpawnedRooms” don’t make new room
Well, for the check it sends a vector with a 50/50 it is right or forward. After the check it gets a random one again. So it can get the same vector multiple times. on the spawn actor node it gets a random one again.
The way to prevent re execution is to store the output of the pure node in a variable, then use only that variable afterwards to connect to other nodes.
how is [1] [2] and [4] any different? you’re giving me bad advice here without explaining i get what your saying but its not applying to the problem at hand in the way it checks the vectors
The way I see it you are checking for a random vector in that array, then adding a different random vector in. How is explaining why that happens bad advice
Where do you want the set connected to? before check already exist or some point after? it shoudnt be hard to recreate in its entirety either if you wanted to prove me wrong
You set the variable correctly. Then use the output pin on the variable node to connect everything else (the check, the add to array, the spawn nodes).