0 votes

For my npc movement AI I'm using godot's built in AStar class, it works pretty well except that when there are 2 possible paths (for example, go up then right or go right then up) it always picks the same one (right first then up), it's never random.
How could I include randomness to the paths?

in Engine by (23 points)

1 Answer

0 votes

You could either temporarily or periodically adjust the weights of the path points in question, by a tiny amount (say 1.0 to 1.01). Or you could temporarily or periodically disable and reenable said points. If you didn't want to keep track of those points on a per path basis you might just periodically sweep the grid, toggling weights from 1.0 to 1.01. Just my two cents since I haven't actually begun programming yet :P

by (20 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.