Hello everyone, I just started learning blueprint, I try to be able to select one or more of my AIs and move them with a move to. For the moment I draw a line to select my AI but I can only select one at a time.
I’m trying with getAllActorOfClass but I’m not sure how I can “list” selected AIs…
(All my AIs have the same blueprint, and I need to be able to spawn them in game) does anyone have any idea how I could do it?
Your Question is very Confusing. Not sure what you mean by Selected (stored in a variable?) and drawing a line (Linetrace?)?
Anyway you can store your AI refferences in a Array and loop over them and call any functionality you have on them. Or get any property they have (assuming you got a bool Selected or something in there)
This Video will help you with Communication in general: Blueprint Communications | Live Training | Unreal Engine - YouTube
Good Luck and feel free to add additional information if my Answer did not solve your Problem.
by selecting I mean like in a rts, and yes LineTrace. I did some screen of what I have for now.
In fact I call a widget when I look at one of my AI with several orders (follow me, defend, …)
Widget :
https://i.imgur.com/jK1YGmA.png
the line trace leading to my selection event and the “get all actor”:
https://i.imgur.com/Kit1dd1.png
and the selection event on my Ai :
I know it’s not supposed to work like that, but I do not see how to do it
Result: Screen capture - 064dc90f7d74d068964b38e47ba4182a - Gyazo
It even fits on one screen
Note: Widget graph is completly empty just a button and text there.
Everything is covered in that single screen. I added a text Component just for visuals. You can replace TPS Char with your own Pawn just make sure to do the Toggle Selection Event inside your Pawn. Everything else adjust to your liking. And sorry for Spaghetti to lazy for 2 Screenshots xD
If something unclear feel free to ask.
thank you very much this is exactly what I am looking to do.
I just have a question, how do I make the TextRender variable? I do a renderTextComponent but it does not let me plug it in
Ok i get it, need a component lol
the “myFollowButton” variable is from your widget button? I can not plug mine into the bind event
Yes its whatever you named your Button inside your Widget (is Variable must be checked). If you get a Ref to your button drag a wire out and type “Assign” and you get all assignable Callbacks like OnClicked etc.
it’s good, I had the wrong bind event…
in fact, if I understand with your blueprint it would be necessary that the Ai is a copy of my ThirdPersonCharacter?
I have tried with my Ai and with a copy of my character all works well, I can select but the “forEachLoop” does not seem to fire
https://i.imgur.com/4gQHS2a.png
Yes naturally it won´t work =) I pointed already out that you need to move the Toggle Event to your Pawn (including the bool) and as you can see you have a branch there that asks if “self” is selected (will only add your TPS character, never the other Pawns)
You want to see if the Pawn is selected and if he is than add him to the array you will loop over later. Just a simple Logic mistake. Everything else looks good to me.
so… like that? https://i.imgur.com/VCM421x.png
https://i.imgur.com/h4gCB3c.png
(the “is Selected” is on my PetitSinge_BP (Ai))
For eachLoop still does not fire… (I can select, everything else works)
Sure add this to your Pawn and change the loop to call the Event instead (or set the bool directly) But I think you slowly reaching the point where you want to look into Behaviour Trees
ok i did a Verifying process and everything work now.
But when my AI reaches me they Stop.
An idea how I could loop it? I tried with the “on succes” on the foreachloop but I get lag, as I expect it
Thank you you help me so much…
I will take a look but my AI is really simple I do not think I would need this for now