Humanoid does not move completely

Reproduction Steps

Well, this can be achieved in any game. Calling the function ‘MoveTo’ on Humanoid makes the humanoid go to the position; however, it stops before reaching the exact position.

Currently I have a code that tells the Humanoid to walk to a Target and if the distance between the NPC and the Target is less than a certain distance, then he just stops moving and attacks. However; the issue here lies on the NPC never reaching the Target’s position and just stops prior reaching it.

This issue is not caused because of the 8 seconds timeout, neither is anchored.

Code:

if (NPCPosition - TargetPosition).Magnitude > Radius then
      Humanoid:MoveTo(TargetPosition) --> This is useless since the Humanoid literally just doesn't move, it stays there.
else
      print("Attack!")
end

Expected Behavior

I expect the Humanoid to reach the exact position, if possible, in the axis X and Z.

Actual Behavior

The Humanoid never reaches its goal position. It stays at some “random” studs from it and is tedious since I am expecting it to move in that exact position and stop at the right spot. Sometimes is even 1.5 studs behind the actual position and even if you call MoveTo again it just doesn’t work because the Humanoid decides to not move.

Look at the distance, between the Position passed to MoveTo and HumanoidRootPart’s position:
image

Workaround

I just extend the distance checks, but this literally breaks the behavior I want since sometimes the Humanoid does reach its goal position making it an issue if I do this.

Issue Area: Engine
Issue Type: Other
Impact: Low
Frequency: Often


(I tried searching for this issue and nothing related to it showed up; please link me a post if you found it to delete this)

4 Likes

Is the humanoid root part anchored?

No, is not anchored, the humanoid is following me, and he is supposed to stop right before reaching me and attack. However, since the distance between me and him is never accomplished because he stops prior reaching the exact distance, he just doesn’t attack.

image

She is supposed to reach that position (red mark), however, is stopping prior reaching it. Is a Humanoid bug since this issue does not occur with AlighPosition.

Hm, I don’t have an exact answer sadly right now sorry - due to me being on mobile. I’ll see if I can find a answer once I’m on my computer

1 Like

The behavior of MoveTo still remains the same. The last time I recall it being updated is when they stopped requiring the “Part” parameter. Does adding the parameter fix the issue?

Additionally, the Humanoid will move to the part or position just enough to get the model in-bounds with the target.

However, I cannot determine whether this is intentional or not due to the documentation being unclear. In other words, it is up to the software engineer to decide whether this is intentional or not.


For a workaround, you could attempt to use the newer Move instead of MoveTo.

1 Like

Since Move kinda works like if you were applying a velocity to a part. (Just that WalkSpeed is already the one used * the direction provided). The Humanoid could move depending on how high his speed is passed the target position (meaning I would have to teleport him all the way to the position). I also have to track until he reaches there to stop him, instead of a MoveToFinished.

Is there a work around for the Target passing it’s position because of his speed (without teleporting him back)?


I haven’t tried that parameter for it, but if I were to do so I guess I will have to create a part every time I want to make any Humanoid move to a position then. (Since they just follow the part and using the same one for everyone would cause issues)


This is what I thought at first, but I hope it isn’t and is just a precision bug. Just like Constraints (AlignPosition for example) that can have sometimes some really small studs in difference.

Are you referring to the unit vector passed to Move changing the velocity or something with MoveTo?

You can create a unit vector by subtracting the two positions:

local moveVector = position1-position2
local moveUnitVector = moveVector.Unit
humanoid:Move(moveUnitVector)

Many old NPC systems created a part like this, but I think you can set the part to the target’s head or torso.


Maybe you can make the humanoid move towards the enemy even more after MoveTo?
Try adding

local look = humanoid.RootPart.CFrame.LookVector
humanoid:MoveTo(humanoid.RootPart.Position + (look * 2))

and see if it works for you.

1 Like

Replying to these two parts:

Ok so, let’s say you make it move to that direction and the speed of the Humanoid is 60. If you make a code that checks every heartbeat if the humanoid has “reached” that position by using Magnitude, it won’t be accurate since physics already made him move even further. You know what I mean? Like he is running 60 studs per second (It depends on how many times Heartbeat triggers per second), and he can pass the point you want him to reach.




In the main post I said: “I just extend the distance checks, but this literally breaks the behavior I want since sometimes the Humanoid does reach its goal position making it an issue if I do this.

In other words, he could get closer to me if he decides to move completely, which is what I don’t want.


By the way, I just tried with a Part and the issue persist. I wish it were to behave like AlignPosition and stop right in the position you want it.

If the Humanoid’s speed is too high, he will pass the position with MoveTo: WalkSpeed = 120
image

With AlignPosition is not an issue at all, he goes right to the part. I am wondering on whether to make a feature request instead…

I see what you mean, but it is also possible to calculate this out, since Move doesn’t need to use all of the walk speed if it is lower than a unit vector.

Let’s say you have a Humanoid with a walk speed of 60, and it is 1 stud away from the part. Instead of calling Move(Vector3.new(0,0,1)) you do Move(Vector3.new(0,0,0.015)) and it lowers the walk speed for only the movement.


However, it seems to be more accurate if I change the density of the body parts up. Maybe try that?

You could try, but you would probably need to request for a new method or for a change of functionality.