I have a bot that uses a “simple move to actor” node. So for the goal I use “get player character”. This is working fine and the mob follows me. Now lets say I want the mob1 to move to mob2. Mob2 is of a different class. What do I plug into goal/actor, in the “simple move to actor” node? And what if there is more than one mob2 in the scene? I would like mob1 to move to nearest mob2.
Any help would be appreciated.
Hello,
Maybe a get all actors and get loc could work then compare locations to define the closest one (not sure for the best method but i remember some radar talking threads maybe usefull for that to define closest mob) and then set a variable with it and use this variable for your move to actor ?
Hi. I am not sure how to compare the locations of all the actors. When I get all actors of class, I get an array and then I dont know what to do next. Ty for reply
From answerhub : Get all actors in distance ...? - World Creation - Unreal Engine Forums, where you store the length output and the character in another variable. You compare on your loop to each new member of the array (replacing the make literal float node). Each time you compare you save the shortest one and update character when needed then you use your variable.
Edit : You’ll need to set your length valu high at start to have it working.
You create two variables, one float SelectedLength one “NearestEnemy” = “actor from class” that you selected. you set SelectedLength a high value. Then on loop, each time new length is shorter than the saved one (on true) you set selectedLength and “NearestEnemy” with actual values" from length and array element.
Then from the completed output (not from the loop body as you did) you set your “simple move to actor” with your "nearest enemy variable as target.
I let you try by yourself to discover arrays but if you have issue, don’t hesitate to come back.
Edit : The controller has to be the enemy controller. you’ll can drag it from your reference. And if your enemy is spawned you’ll may have to add a spawn default controller too to have it working.
It would be something like this :
The spawn default controller is needed only if you didn’t set your enemies in level but spawned them.
Too shy for that. To be honest, I still need to make a lot of different gadget’s and to have more than one enemy model, and some actual environment, before I will dare to make a WIP thread. Cheers!!!