Pathfinding patch
Changes
When we call Humanoid:MoveTo() from waypoint to waypoint, and use the MoveToFinished event to detect when the character reaches each waypoint it does work. However unlike the demo place and code portrayed in the documentation on Character Pathfinding, many games will not operate with smoothness due to the event having a delay on being communicated, leaving a stuttering NPC between nodes and overall a poor visual effect.
This is detrimental on considering performance in public games, unlike test baseplates with minimal events and memory.
To resolve this issue, I implemented a snippet of ClickToMoveController under Player > PlayerScripts > PlayerModule > ControlModule.
You should notice that ClickToMove controller does not register for MoveToFinished but instead uses its own logic to decide when to move to next waypoint - namely the RunService.RenderStepped event. This would avoid waiting for the delayed event.
https://devforum.roblox.com/t/npc-moveto-has-a-stuttering-effect-whilst-using-pathfindingservice/3067241?u=m_etrics
Checks
By submitting your pull request for review, you agree to the following:
- [X] This contribution was created in whole or in part by me, and I have the right to submit it under the terms of this repository's open source licenses.
- [X] I understand and agree that this contribution and a record of it are public, maintained indefinitely, and may be redistributed under the terms of this repository's open source licenses.
- [X] To the best of my knowledge, all proposed changes are accurate.
Hi @metricrb , this looks like a great change, but I tested it briefly and my character stopped at the first waypoint (did not continue onward). Could you please check how it works for you, or point out what may be happening in my test?
Hi, @IgnisRBX, you are completely right. It seems that the example code I submitted had a small mistake caused by me when I was copying it out of my game systems to function as an example. Please try again with the most recent commit. Apologies for any inconvenience.
Hi again @metricrb , I tested your updated code and it seems now that the character is attempting to move toward the final waypoint in the path, not the next one in the series of waypoints. Are you seeing the same behavior?
This pull request has been inactive for 14 days. If it remains inactive for another 7 days, it will close. Please update or comment on this pull request to keep it open. 🙏
This pull request has been inactive for 21 days. It's closing now. Please feel free to reopen it if you still need it. 🙏