Hi, i am having trouble finding the correct way to spawn Actor the furthest possible by using world location from different elements out of an array.
At the moment i “Get World Location” → “Vector Length” → Store this value in a Float Variable and if this variable is higher than the second one, i set this value in the second variable. Then i set the last choosen element as my Exit for Spawning a new room.
The issue is that if one of my rooms has only one Exit and this Exit has a smaler value of World location, the last used Exit that is still further away keeps getting chosen and my whole thing gets stuck.
On this screenshot the red arrow is pointing at the only possible exits as the last room placed was a left turn, the black one being only the overlaping room trying to spawn. The green arrow point at the last used exit (used to spawn the last room).
I can’t say specifically what’s wrong with this setup, although spawning and then checking if it was ok is a waste of time. Much better to spawn correctly the first time
This = 0 btw
Rather than trying to manage the spawning from a central piece of code, which is always going to be fiddly, why not let the current room spawn the next room? Then you know exactly where to put it.
Hi, I managed to solve some issues. I now remove the “Selected Exit Point” from the list of Exit at some point in my Overlap checking / Delete overlapping room.
Now it work fine most of the time, and if it does not, it’s because it spawns multiple time a “Turn Left” or “Turn Right” making a loop with no exit available.
I was aware that by subtracting the variable by itself it would set the value to 0.
It’s what I wanted, there must be a better way to do it but it did the job.
I still have few questions, is there a node that could check if the chosen element out of a random array is already in the current level ?
Or another way for me to prevent those “Turn left”/“Turn Right” loops ?
I tried using “Is Valid Index” but didn’t manage to make use of it properly.
Also, I did not quite understand how to let the current room spawn the next one as you say. If you have some free time, could you perhaps give me an example ?
You can take them out of the array after randomly selecting them. Once you’ve used the last one, you can repopulate the array.
Right now, you’re doing everything from a central point, the level BP perhaps? Another way, is to put the spawn code in the room BP. On overlap ( or something similar ), the room can spawn the next room, and that way know if it connects properly or not.