At the moment, I am working on a pathfinding AI agent. I noticed that it gets stuck sometimes. This happens because it keeps waiting until it hits a certain waypoint. My agent waits until the event
Humanoid.MoveToFinished fires and then continues his path. In some cases though, this never happens because it is completely stuck. So somehow I need to detect this and maybe update the agent’s path.
So I thought, what if I can set a timeout for
Humanoid.MoveToFinished:Wait(). This way, I can detect if it is stuck. The issue is that I have not really come up with a nice way of coding this. How can I wait for either an event to fire or some delay to time out?
I thought of maybe wrapping the idea in a promise, so that I can use a then and catch if it fires or times out. An actual implementation of this idea is still missing though.