Help Using Multiple Ai to go to a Table /Chair

I am trying to make a simulation game. Where i wait for NPC to go to tables and sit in a chair. I have it going to the table, but once i set the bool to occupied using ai move to on the success pin. it should no longer use that chair for the next NPC that enters. even though i have get occupied put in to a branch and for it to do nothing if true it still runs the task again and still end up going to that chair that occuppied. when it should not it should choose the other chair that available. i feel i am missing a step somewhere but been trying for the past week to fix.


The branch with the greater than or equal to “chairs full” condition seems like a problem. It should check a different random chair instead of just letting the AI take the chair if the condition is false.

Sorry if I am way off, but maybe look into it.

that condition check is onlyl incremented once a chair is occupied. even with out the check the ai still goes to the same chair. it like the bool get occupied is being ignored.

I see, my only other guess would be the random integer nodes calling random things each time it is called. I usually save the random value into a variable so I don’t have to worry about it but those might be calling random ints each time.

how would i retrieve the chairs that are not occupied then with out the random int. i am thinking that the issue to, but i dont know a way to call for them to go to the chairs sincee there multiple of them in the level. and the number of chair can change this is a management style game. should i just be doing random from the array or what the best approach.

I would use an array for the chairs. When a random one gets assigned, remove that chair from the array so it can’t get assigned again. Another array would store the chair number as the value and the index value would be the AI who took the chair, so you can remove that when they leave. I don’t know all the specifics of what you are going for, but that is how I would handle something similar.

I would get rid of the random integer thing altogether if its not necesary. Put the chairs into an array, shuffle that array, and then assign and remove index 0 when someone wants a chair. When the length of the array is 0 there are no more chairs. Seems easier then dealing with random ints.

not sure what i am doing wrong i am new here to bp. i am just trying to set the chair to occupied once the ai is at it location then once another one spawn it pick the next available chair. even with setting up array it goes to same chair. i am probably not doing this code right at all

That’s gonna return completely random values each time a new node executes as well. You have to save the index of the random value into a variable and then use that to point to the random item. Or shuffle the chairs array once and use that order.

i use smart objects instead that was the easiest to set up for me with little work needed. i now have my npc detecting the chairs available and claiming them once there. i appreciate the help.