Branch nodes in procedural generation

Hi, im having a bit of trouble getting the right actor to spawn. I spawn a room actor with a random amount of doorways then depending on how many doorways there are i spawn the door actors in the correct location. Instead of detecting the doorways im trying to detect the room actor so i know how many doors to spawn using a branch node, if its this room spawn this many doors, but it seems to be ignoring the condition. Iv been looking at a lot of tutorials on youtube but cannot figure this out. any help would be appreciated.

Consider demonstrating the piece of code you believe is failing, a screenshot helps.

Accessing a *random *node more than once will potentially generate numerous different results - not saying it’s the case here but it’s a fairly common trap.

Hello :slight_smile:

You have to input the condition you need to verify by linkning the red button on the left (boolean needed).
You can put a <= / >= (lower / greater than) block or a calcul … as you wish while it is booleanable :wink:

If the condition is valid, then arrow “true” will continue, else arrow “false”

you have to find a way to link your actual spawned room to that bool. One option would be checking the name of the room, and if it contains the number 1 spawn 1 door if not spawn 2 door etc…

thats whats boggling me. iv tried using actor object and class references and using ‘is valid’ nodes with no success. i set spawn room 01 as a bool to see if its present or not but i dont know how to connect the bool to spawn room 01. could you show an example of setting up a name check pls.

You have to imagine that your blueprints are dumb, and they only know what you tell them, they can’t really figure things out on their own. So you have to be very specific.

I’m not sure how you have your blueprint setup to spawn a random amount of doors.

If you have a different room static mesh, for example room_01 has 1 door, and room_02 has 2 doors, then you can read the static mesh name from your actor BP, and spawn the doors based on that. Here is a simple example

This is the room blueprint

Here is the level blueprint to check for the name of the static mesh (you need to get the static mesh component first, and then check the actual static mesh assigned to it)

A better option is to have a variable setup in the Room BP, that defines the number of doors (I am guessing you are using a variable like this somehow)

Something like this

If you have this, the only thing you need to do after spawning is read this variable, and spawn the number of doors based on this.

You can either use boolean (good if you only have 2 options, ex 1 or 2 doors, 5 or 6 etc)

Best option is to use either a Select on INT node, or as I am using here a switch on int. This basically reads the value, and does an action based on what that value is.

So in this example if the number of doors is 1 it’s going to generate 1 door, if it’s 10, it’s going to generate 10…

Thank you for this. i am still having trouble though. is the current room node an actor reference? i can connect set current room but cannot connect get current room in any of the examples. if i change it from an actor reference then i cannot connect the set current actor node. by promoting the target pin from number of doors, (which becomes spawn room 01 object reference), i get an error ’ accessed none trying to read property newvar’. i also cannot connect a set newvar node to spawn actor. i have four spawn room BPs, one is randomly selected and spawned and then i am trying to tell the engine which room has been spawned so it knows how many doors to spawn. i have got the transform sorted for all of the doors but have been unable to tell the engine which room has spawned. i am only using true or false for the first room to practice, e.g. if room01 spawn one door if not spawn 2 doors.

Success, i think. i took a break and then tried the first example again but left out the geometry room and static mesh nodes so it goes current room, (which is an actor reference) get object name, contains and i have added all four spawn rooms into the mix and it works fine. thank you for all your help.