AI patroling skips positions - no idea why

So my AI’s behaviourtree consists of 2 functions:
1st: gets the first patrolingpoint out of an array stored in the pawn puts it into “MoveToPosition” on a blackboard and puts the vector at the end of the array( delete index 0, add stored vector)
2nd: the pre-existing “moveto”

The problem is, the AI now anounces the first point(print string at the beginning of function 1) and walks there
once there it anounces point 2 and walks there
NOW THE PROBLEM (in action): it just announces point 3 immediately followed by point 4 and walking over there
after that he skips 2 points and goes to the third
after that it starts over again - skipping 0, then 1, then 2 points

The images show the behaviour tree and the funcion( the second sequence you don’t see doesn’t make! a difference if taken out and neither do the decorators)

So, any ideas where the skipping comes from? (and why it seems to increase with each point?)
Thanks for your help

Is the patrol path circular? 1->2->3->1? Why are you removing index?

Yes, it’s circular. and my thought was “take index 0 to blackboard, remove index 0 and put it in the end” that way the order doesn’t change and the next position is always at 0 and I don’t have to keep track at which index I should read the next position
Also it shows the positions via printstring and they are all in the order I put them in - it seems to have a problem with the behaviourtree itself, but I have no idea why, since it’s only “get next position” and “go there”
but he seems to skip “go there” 0,0,1,2 times, but always the same positions

I narrowed it down, though that doesn’t help me in the slightest:
as I expected the “move to” task just aborts and I have absolutely no idea why, because it has no conditions attached, it just only works on the first, second, fourth and seventh call… and for whatever reason the eights one is like the first one - it seems like it restarts with the array beeing gone through, but it has nothing to do with it and the blackboardvalue “move to” uses is also set correctly, so yeah - anyone any idea? it just doesn’t make any sense…

It’s hard to tell exactly what’s going on - but doing those operations to the array is not a very good idea. Try using modulo access instead, see this for an example:

Doing that will always return the ‘next’ location and you won’t have to worry about constantly reshuffling the array.

I just tried it - now the pattern he “ignores” the values changed - he now walks to P1, for whatever reason just aborts “move to” P2 and P3, “move to” P4, P5 & P6 work and P7 don’t - and then he restarts - I think there has to be something wrong in the “move to”… I read somewhere about an incident with having hundreds of AIs using “move to” was to slow to change some variable or so and “move directly toward” made it work, but I tried that to and it didn’t made any change
-------------------EDIT: nevermind the change in pattern, I didn’t cut out my solution with the shifting - so the skipping sticks to the 0,0,1,2 even with your method

Simplify. You are doing something wrong. It’s probably not an issue with Move To. In that video I have lots of them chase me..

You can drop the attached example into blank Third Person project and have a play with that. Set lots of debug points on every calculation, see if you get the right values on initial calculation and subsequent variable setting. If all else is fails, upload the project to Google Drive and I’ll have a look for you.

I’ve rebuild the Task 1:1 in an empty 3rd Person Template and it works without any problem… I still don’t know why it won’t work in my project, but if neccessary I just migrate everything into another project if that helps - also I was pretty sure there was no problem with my own task since it always showed the points in the correct order - also I saw that it always stopped at the “move to”( I show this from beginning to first problem in the 11 screenshots in the zip attached)

Do you know why everything is red in Screenshot 11? It looks like first branch should be executing, but it’s not ? This is odd, like I said before, happy to look into your project if you want to upload it somewhere.

thank you, but for now I think I’m just gonna rebuild it in a new empty project, don’t really feel confident into sharing the things I made while prototyping

Sure no problem. Just remember, however bad it seems, I’ve probably done worse at some point.

So, not gonna lie, that method of rotating patrol points is just asking for something to go wrong. While I can follow the logic, I am telling you from personal experience dealing with arrays that sometimes they don’t always do what you expect and since it is hard to dissect out what is going on in an array at any given point (it’s kind of a black box in that regard) this set up is prone to errors. My suggestion even if you aren’t gonna like it is…keep track of the array index. It is not that hard. Create one integer variable and call it counter or index whatever you like, after each “get” where you pull a patrol point from the array then check it against the length of the array, if it is greater than the length reset it to 0, if not, increment and repeat. This is much simpler honestly and much less prone to error than trying to shuffle array elements around constantly.

Thank you for the suggestion, after gk0r came with the math for it I realized that that’s better than rebuilding the array every point, so I already use it - but the “move to” still just aborts at the same pattern… but since it’s no issue in an empty project I think using “ctrl+z” or something else might have done something in the background and now I just mess with my project until I have everything working at which point I’ll use it as a blueprint to rebuild it in a clean new empty project - but still thanks for the tip, I realize it’s important enough to be said at the end :slight_smile: