How do i get the index number of one actor to get a variable only from that actor while having multiples of it on the level?

How do i get the index number of one actor to get a variable only from that actor while having multiples of it on the level ?

I have 20 of these actors on the level and many AI characters.

What i want to do is when 1 AI interacts with 1 of these actors another ai cant interact with that actor and needs another actor of the same class to interact or wait until the 1 ai stops interacting with the 1 actor.

Its kinda like when someone sits on the seat the other one needs to look for a new one or wait until 1 seat gets empty.

But whenever i try to run it with an example of 2 actors and 2 ai characters both interact with the same actor and i think its the reason that i cant reference the actors splitted. I used Get all actors of a class choosed that actor and then i did Get and there is an index i tried 0 and 1 and it still did the same as before both ai interacted with the same actor what i need is when 1 of the ai interacts with 1 actor the other ai has to interact with the other actor.

you can set a “taken” variable on the chair (i say char cause of the sit example you bring) and then when the AI has to choose you can call For Each Loop and search an array element that is not “taken”. On completed you just get the AI to go sit there. Hope it helps. Btw get all actors of class is a really expensive node for the cpu, use it wisely.

Change the Variable as soon your AI starts to interact with that actor. You probably have something like a Overlap event I guess? Thats where you want to hook up to, the overlapped Actor is provided Cast to the specific Actortype and you can access the variable.

Take a look at this Tutorial to get up to Speed with Blueprint Communication in General.

Starting Positions

Ending Positions

This worked but i still need to know how i can seperate all seats from another like the player index thing or so, kinda like calling to the engine hey this ChairBP is 0 and this ChairBP is 1 and this ChairBP is 2 and so on… so they are not the same actor in the level but still same blueprint class. I dont know if thats made with an Index, Array or any other variable type but this way with a variable would make it easier to me to work precisely instead using a premade blueprint node since i am not a Pro UE4 User or a programmer, i still understand decent programming logic. Its kinda like knowing that 3+3=6 but not knowing its called three+three=six so i cant communicate with the engine well yet for using shortcuts like you showed to me and building other proccesses over it.

Thats the Chair Actor

The BT controlling the ai

The BT Task

In your BT Task → Loop (with break) over your Chairs array. Check if Chair is Empty. If True set it as Target for your Move, Break loop.

On Loop Complete check if Target is Valid (we found a unocopied chair during loop) Finish execute with Success, otherwise Finish Execute with Fail.

That should get you started. You got todo a couple more things after that Like checking what the Closest Chair is, Interupt running to a Chair if someone occupied it on the Way, etc. but thats a entierly diffrent Question. Good luck.

Thank you for the information about the get all actors but sorry i couldnt really understand what you exactly mean with that search an array element by a boolean thing would be nice if you could post a screenshot about that.

I tried that but couldnt figure out how to use the arrays. Did something like this according to these you said not sure if i did the stuff right else then the array thing IsValid? for an example.

Would be nice if you could explain what IsValid does and post a screenshot for how i can set this thing with arrays up.

Btw after i did this and started play it did the same both moved to same chair and that probably because i couldnt difference both chairs from each other.

I think i have to reference an array to explain the bp these chairs are different in that red box but dont know how to.

You just need one Target location for your Blackboard. No need to track every Seat by Hand or differentiate, all you wanna know if there is a Seat Empty → thats where I go.

Add the Nodes and wires in Green its a simple Chair refference name it as you like. Leave the first Set Node Empty (its a Reset to nothing) the isValid Node simply Checks if we have a Refference or not (have we found a Unoccupied Chair?)

You can Shuffle your Array first if you like so they all dont run to the same Chair. Or you can Set “CanSit?” to false right after you set your Blackboard key just as Test so its “technicly speaking occupied” as soon someone choose their Chair. But thats all up to you and the desired behaviour you want to have. Play around.

Good Luck mate if there are any Questions left let me know.

What you ask is usually a Bad Coding Practise. Because you have to Change your Code everytime you add or remove a Chair. The Engine itself gives you back a Bunch of things it finds in no Particular order so you can´t trust that it always returns you the same ordered array. Therfore you have to Manually identify what you looking at. (Still don´t advise you to do it, Bad practise)

Anyway if you really want to go down that row create a Variable in your Chair BP. You can use a String or Int and make it Editable so it shows up in your Editor to easily change it, I call it “Identifier” for refference. Make sure to select your Chairs in the Editor and Change that Variable to something Unique.

In your loop you can “Get Identifier” from the Array Element and compare it against a Int or String of your choosing. You got to create a Switch or a Branch for each comparison and add everything by Hand (thats why its also a Bad Practise ;P, more work for no reasson). If the Comparrison is true you succesfully Identified the specific Chair you want and you can do whatever you like with it at this Point.

Thats it. But I really hope you don´t go the Bad way. Think more in Abstractions. In your case the only thing you looking for is a Free Chair not any “specific” one or in terms of your example instead of 3+3=6 think of x+y=z.

Good luck =)

Since i wont add or remove any chairs, this way by hand, manually (Bad Coding Practise) is better for my purpose in wich i dont only look for a free chair. And in my example with 3+3=6 but dont know three+three=six i meant that that i dont understand the premade language of the engine to communicate with it well yet to do most things over shortcuts or premade nodes so i make them myself with variables like that. x+y=z thats what i know too but dont know that its called iks+why=si so i call it eks+way=sy and to do so i have to make it by hand and manually for full control in my perspective but from someones perspective like you wich is experienced its probably better to do it as you said but since i am not that experienced, i would need to ask every other steps too wich i may will but this way probably not every single one of them xD.

Thank you very much for your help.