Big Humanoid start spinning when getting close to target (:WalkTo())

Hello,

My pathfinding module works correctly with smaller rigs, but when it’s used with a bigger one, it starts spinning hard when he is reaching the waypoint position.

I’m getting my path throught the regular method, and then doing a loop with movetofinished:Wait() before going to the next pos.

Any idea on what could be the origin of this uncontrollable spinning ?

     ...

function Move:CreatePath(Start, End)
    local Path = PathfindingService:CreatePath()
    Path:ComputeAsync(Start, End)

    return Path
end
     
     ...

    local Path = self:CreatePath(Character.PrimaryPart.Position, Part.Position)
    local waypoints = Path:GetWaypoints()

    self.waypointFolder = Instance.new("Folder")
    self.waypointFolder.Parent = workspace   

    local Points = {}

    for Step, waypoint in ipairs(waypoints) do
        local part = Instance.new("Part")
        part.Shape = "Ball"
        part.Material = "Neon"
        part.Material = "Neon"
        part.Size = Vector3.new(1,1,1)
        part.Position = waypoint.Position
        part.Anchored = true
        part.CanCollide = false
        part.Parent = self.waypointFolder

        Points[Step] = {
            Part = part;
            Position = part.Position;
        }
    end

    for _, waypoint in pairs(Points) do
        self.Humanoid:MoveTo(waypoint.Position)
        self.Humanoid.MoveToFinished:Wait()
        waypoint.Part:Destroy()
    end

     ...
  • rig Size :
    YSize = 28
    HipHeight = 10

Thx for reading :slight_smile:

2 Likes

Weird Solution for weird behaviour.
It seems like autorotate of the humanoid was the problem.

I solved my issue by setting that value to false at the start of the code and true at the end (cuz I need that autorotate behaviour somewhere else).

And to make the rig face the walking direction I added a :SetPrimaryPartCFrame() in the loop before the :WalkTo().

This might look a bit odd when the rig has to take big turn, but it’s better than him going beyblade mode.

If you ever find another solution to this, don’t hesitate to reply : )

1 Like

This is a fun error. I have done this myself. It’s actually doing what you told it. The model is trying to get to a spot on (or possibly even in) the floor, based on a spot way up in the air (the hip height of a large model). It gets close, the orientation moves to the left, and he starts travelling in circles trying to reach something he can never reach.

I believe you need to set the Y coordinate of your pathfinding script equal to the hipheight of your humanoid. This should eliminate the spinning.

1 Like