How do I go through an array in index order?
So i'm trying to make a one-button game by drawing a path with the mouse and when released the character is going to walk that same path. I'm kinda managing by saving the location of the mouse when the left mouse button is pressed every 0.2 seconds in an array. Then when left mouse button is released I would like the character to walk that drawn path in index order. I manage somewhat by doing every single index, but since that would in the end create way too many similar nodes with just adding +1 to index, I'm wondering if there is anyway to make some sort of loop that walks to index 0, then index 1, index 3 etc. In order and also not at the same time, so the character actually makes way towards index 0, then index 1 and so on.
asked Dec 15 '14 at 01:12 PM in Blueprint Scripting
ForEachLoop. Then put a delay in the loop to cover how long it takes to walk from one point to the next.
answered Dec 15 '14 at 01:56 PM
Did you already look at behavior trees?
It might be a bit overkill but they allow you very easily exactly what you need.
The tree will do tasks one after another. You can create a talk which selects the next point in your array and put a move to node right after.
It will select the point, walk there (if possible) and then execute the next task (again the point selection).
As I said a while behavior tree for something like this might be a bit overkill but it is quite a valid option.
answered Dec 15 '14 at 03:03 PM
Sorry for such a late answer, but thank you all! With the help of a foreachloop I got it working :)
answered Jan 10 '15 at 10:28 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here