The code you made will give you a random direction every frame, which will make your character look like it bugged. How I would solve this is use lerps or timelines to smoothly change the characters movement direction over time and use sine node to flip-flop between two vector directions. This would create the movement in the image. You can also change the speed and range randomly, so it is less predictable if you want that.
i am pretty inexperienced with AI, but I was under the impression that you’d need to find navigable points along the way, and one by one move to them, like waypoints.
So it would be more like, calculate final destination, then get an array of navigable points between current location and final destination, then move to each and on move complete, move to next location in the array.
there is many ways to get zig zag points between here and there - i’m not a strong math guy so my ways are kinda hacky and stupid. somebody else might offer better ideas about that. But the idea is that you make a list of waypoints first, then move.
I am not sure that you can “steer” an ai along its way as it seeks a point. It wants to go the shortest route possible - assuming i understand the system correct;y.
I did something similar once with a custom tree task, that would remember whether the last move was a “zig” or a “zag” and then set it’s next destination to a direction left or right of where it was currently at.
BIGTIMEMASTER’s idea would probably also work.
Probably depends on what you need to do while moving
Alpha for lerp should be between 0 and 1, but I would also do the setup a bit differently. You can generate path points with find path to location node and then use path points vector array to move from point to point and then use a method I mentioned above to make character move left/right. To move from point to point you can use Add movement input and do some vector math to calculate the direction in which the character should go(next path point). In here you can use lerp, sine and delta seconds to make smooth character rotation, while following the general path. I would create and test each part seperately(find path, movement input, zig zagging), so it is easier for you to debug it.