Humanoid:MoveTo() edge cases

I would like to see more documentation regarding the conditions under which Humanoid:MoveTo() stops walking or does not walk.
https://create.roblox.com/docs/reference/engine/classes/Humanoid#MoveTo
What does it mean for the character to “arrive” at its destination? How close does it try to get to the target? If it’s not as close as I want it to be and I call MoveTo again, it does not move because it already considers itself arrived. What can I do to make it more precise?

9 Likes

MoveTo() will make the character move towards the destination point and won’t stop until it reaches it’s destination OR 5 seconds has passed (which is to prevent NPCs getting stuck)

1 Like

On that note, I’d also like to add that it would be nice if we could provide an custom argument to how long a humanoid will keep trying to reach it’s target destination.

Very useful for if you want the time to be longer/shorter than 5 seconds or if you want the humanoid to keep walking forever.

If I could make that a feature request I would.

2 Likes

Hello @1waffle1! Thanks for submitting your feedback.

I checked in with our engineering team and confirmed that the MoveTo completion does not precisely end at the destination. There’s a ~1 stud margin at the destination meant to compensate for various frame rates, movement speeds, and other factors.

I updated the documentation to help clarify this lack of precision.

@C_Corpze, I suggest making the feedback request to the appropriate Engine category! I can see how that would be useful :slight_smile:

I hope you all have a great rest of your week.

5 Likes

Okay, sounds like I should overshoot the destination by 1 stud if I want to make sure it gets reached.
Why ~1 and not exactly 1? Is something more complicated going on? Could overshooting by 1 still sometimes stop short of the exact target position? How far beyond ~1 stud can the margin potentially vary? When calling MoveTo a second time results in no movement, it’s hard to detect.

1 Like

Hey Waffle! I’m sure there are more complicated things and considerations going on under the hood that the team is unwilling to share with me lol, so I’m not sure I can answer all your questions.

Not sure about your overshooting solution (I’m not a pro dev by any means) but my gut feeling is that you might find some complications down the road if you overshoot everything. If you need a humanoid on precise coordinates, a potential practice to try is to use an initial MoveTo() to get to your destination, wait for MovedToFinished() near/at your destination, then programmatically set the final position and orientation of your object. This eliminates a lot of your questions regarding overshooting and the different margins.

I’m sure someone much more experienced in the forums can help you out if you want to open a topic there! Best of luck!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.