This is an old version. I have made a far better version by now, wich you will find here.
I have played around with dummy bots a bit and tried to get some pathfinding done and came up with quite a decent pathfinding-AI. Its not perfect or anything, but as long as we dont have a built-in graph class in workshop, I dont think I can make something better.
ZGTKX - Im sorry that the code is such a mess, I will clean it up later, when I release this as a tool.
Known Issues:
- The bot can’t reach a highground position and chances are low that it will find the stairs, if there are some.
- There is a very low chance that the bot will fall down a cliff - unfortunately I can’t fix this without breaking the algorithm.
Usage (WIP version):
- Walk out of the spawnroom to spawn an ana dummybot
- Go to a position you want and Crouch to initiate the pathfinding algorithm with the destination being your position. Crouch again to interrupt the pathfinding.
- Press Interact and the bot will stick close to you (no pathfinding). Press it again and the bot will stop following. (mainly for debugging)
- Press Jump to toggle slow motion. (mainly for debugging)
The UI (mainly for debugging):
- The blue light shaft and red arrow are marking the (current) destination of the pathfinding algorithm.
- The green and red light shaft are marking the orthogonal vector that is used by the “is-stuck-in-circle-handling”.
- The small messages are displaying the current action the bot is doing (right, left, forward, backward).
- The big message (“2: Error”) displays if the bot is stuck in a circle and the algorithm tries to handle it.
The Algorithm:
- The bot moves directly to the destination (D) as default action.
- If the bot reaches D it will remove it from the array and go for the next destination or end the algorithm if its the final destination.
- If the bot moves against an obstacle or cliff it will turn right.
- If the bot just turned right and detects no obstacle on its left it will turn left and return to the default action after some time.
- If the bot detects no obstacle but still gets stuck (no movement), it will walk backwards for a brief moment and then try again. (This happens if it walks towards thin walls)
- If the bot gets stuck (no movement) but still has a high speed value (yes, this can happen - dont ask me why ), it will be detected by another rule and handled the same way.
- If the bot gets stuck in a circle (is moving between the same positions over and over; this will nearly always happen in small rooms) it chooses a new destination ( D’ ) and walks towards it. It also changes the turning direction from right to left (or left to right).
The dummy bot has a high rate of reaching its destination with this algorithm, even if he seems to behave kind of weird and random sometimes. Some things that needs to be done is cleaning up the code and finding a solution for the rare case that D’ is unreachable.
I hope someone will find this useful and if you like this or notice some cases, in wich the bot still gets stuck, please tell me about it