I have a project that contains 1 NPC (AI) and 2 target points. In the project I can make the NPC follow any of the 2 target points, but I can not get it to follow target point 1 and then target point 2, and that is what I would like to do, so that I can make a path.
What I would like to know:
tp1 = target point 1 and tp2 = target point 2
What I can do:
In creating the variable that sets the target, I checked the box: instance editable. As you can see in the image, I can set the target in the level editor.
Blueprint of the NPC:
When I went to do the programming for him to follow the other target point (tp2) after reaching the first one (tp1), I did not get it in any way. No results appear with my search, which for me does not make any sense, because in the level editor I can easily.
Looking at the level editor / Looking at the blueprint:
I also tried using the Get All Actor of Class, but without success.
Link from where I also looked for help:
EDIT 1 (Attempt based on ColdSteel's answer)
I created a variable of type array of actor called
As you can see, I added 2 elements to this array, but I can not edit any of the 2.
I researched a way to change this, until I got to this link:
Unfortunately it caused an error in the code, causing me to give up for now and look for another way to solve my main problem.
Although I created 2 elements in the array, none of the elements appears in the level editor:
But I can create new elements and define them as the desired target points:
However at the time of defining them in the construction script I again error in some detail:
EDIT 2 (Another attempt, based on Stephen's answer)
With the help of Stephen I discovered how to promote a variable (right click button):
But I still have not got the expected result, see below an explanation of what happens:
Red code (Simple Move) => The NPC moves toward target point 2, without first passing target point 1.
Blue code (AI MoveTo) => Nothing happens.
EDIT 3 (Attempt made thanks to the progress I made with the answers of ColdSteel and Stephen)
This time I managed to get the NPC to do the correct path, but it is not dynamic since the NPC does not go directly from target point 1 to target point 2.
I know the loop executes all at once, so the value registered in the function to move the NPC was always the last.
With the creation of two Boolean variables, I was able to "circumvent the operation of the loop".
With the delay I assure you that it will allow NPC time to arrive at target point 1, only to go to target point 2.
I know that what I did is far from ideal, to have an idea I would have much more problems if there were more target points.
Now I can get the NPC to go to target point 2 immediately after reaching target point 1.
I added a collision box to target point 1:
Changes in the blueprint:
Important to inform, that such a loop was not accused as infinite, since I added a collision box only to target point 1.
Now I have to know how to make a code for any amount of target points.
EDIT 5 (Finally I did it!)
For this I used the "Do N" and added an integer variable that will serve as counter.
Basically, every time the NPC collides with a target point that has collision box, the loop with the "Do N" will be reset, but with the help of the integer variable that serves as a counter, the subsequent target point will be set correctly.
I do not know if this form I found is the most effective and functional. Please feel free to comment and correct me.