creator-docs icon indicating copy to clipboard operation
creator-docs copied to clipboard

Pathfinding patch

Open metricrb opened this issue 1 year ago • 3 comments

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.

metricrb avatar Sep 17 '24 13:09 metricrb

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?

IgnisRBX avatar Sep 19 '24 15:09 IgnisRBX

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.

metricrb avatar Sep 19 '24 16:09 metricrb

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?

IgnisRBX avatar Sep 20 '24 19:09 IgnisRBX

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. 🙏

github-actions[bot] avatar Oct 05 '24 20:10 github-actions[bot]

This pull request has been inactive for 21 days. It's closing now. Please feel free to reopen it if you still need it. 🙏

github-actions[bot] avatar Oct 13 '24 08:10 github-actions[bot]