So Humanoid:MoveTo() doesn’t move the character to the exact position specified. I want to make an NPC walk into an exact position, and not teleport there. Is there any way to achieve this?
Humanoid:MoveTo
doesn’t teleport the character there though? You might be thinking of Model:MoveTo
where this is the case.
This is only true if something is blocking the way, or if the position is up in the sky where it would be impossible to reach.
I know that Humanoid:MoveTo() does not teleport the character, but it also doesn’t move the character to the EXACT position that is inputted. What I’m trying to do is have an NPC move from the center of one block to the center of another block. There is nothing blocking the way between the blocks. Is there a way to do this?
Depending on what you want you may need advanced pathfinding. If it’s just moving to a location without any obstacles what incapaz said should work.
I’ve done some testing and I see the same thing. Why is it you need to to be perfectly exact, When testing mine never finished more than 1 stud away from its target.
If you checking to see if its reaching the location you could just do a magnitude check to see if its close enough and then target a new position.
I’m making a top-down block to block styled game, and I want the NPCs to move exactly to a block.
That is pretty normal for NPCs sometimes there are obstructions, and :MoveTo() isn’t absolutely perfect. If you make the Y position too high for example, the NPC has no way of reaching that. Advanced pathfinding makes it more reliable though, however you may want to look into that. It will be of course be more work though.
When a Humanoid stops moving the MoveToFinished
event is fired. You could wait for that event then snap the NPC into the correct position. Humanoids usually stop within 1-2 studs of the target position so the transition would probably be subtle enough.