I did this script for moving platforms to move along a path, but it can be used also for patrol behaviors.
What this is script is doing is basically move the object this script is attached along a path of nodes, and waits in each node during the specified Waiting Time.
Moving Time is the time to go from a node to the next one.
There is 3 modes for patrol:
- None: the object stops when reaching the target position
- Loop: the object goes through all the nodes in a loop
- Ping-Pong: the object is going forward through the path, then in reverse, once it reach the last node
Editing the path is simple. The first node will be always at object position, and there will be a minimum of 2 nodes.
You can add a node by selecting one of them and Shift + Dragging the node.
You can remove the nodes by Ctrl + Clicking on any of them
And finally, you can drag any of the nodes by dragging any node or move all of them in block by moving the parent object
Holding Ctrl while dragging a node will snap its position
Download the scripts for this behavior here