MoveTo() seems to be broken

So, in my tower defense game I’m using MoveTo(), for mobs to move at waypoints and then script waits until mob finished moving with MoveToFinished:Wait() and then going to another checkpoint
But, if you anchor mob or set it walkspeed to 0, after some time it will “reach” waypoint while its not, making it be that mob haven’t reached end, but still damaged base

Is there any alternatives to use, so it dont happen like that?

MoveTo() is meant to timeout after 8 seconds when stuck, otherwise MoveToFinished won’t fire. When the enemy gets stuck, not through intentional means, if the timer did not exist, the enemy won’t be able to move until what is making it stuck is resolved. Utilising the timeout is generally more favourable since you’d want to check if the path is obstructed when the enemy becomes stuck.

The Creator Docs recommends continually firing MoveTo so that the time resets.

1 Like

what if I use tween to move mobs, how I would rotate them to waypoint

Use the PrimaryPart of your enemy’s models, and animate it with CFrame. So long as your enemy’s Parts are properly welded, they should follow with the PrimaryPart.

So I just tween mob’s primary part CFrame to waypoint CFrame and then it should be good cuz they already welded? (Will it rotate to waypoint instantly though)

1 Like

You’ll have to set the enemy’s orientation before Tweening if you want it to face the next waypoint instantly.

Do you wanna use set primary part Cframe

Like, how to, I not really understand

I didnt even knew dis thing exists

Example :

model:SetPrimaryPartCFrame(CFrame.new(0, 10, 0) * CFrame.Angles(math.rad(0), math.rad(90), math.rad(0)))
1 Like

I tried doing this, but, mob stops at waypoint for a while because it tries to move at previous waypoint, and when setting to next waypoint it does move, basically it stops for awhile, even tho I have checks.
maybe just set more time to wait

I removed wait time absolutely and it seems to work now, I’ll wait more time when mob is frozen to be sure. Yes, it seems to work, no matter how much I wait mob still moving to same checkpoint, when I unfreeze it also moves normally after it, and if I freeze again, it still works as I want. Thanks.

I also may see how tweening looks like (moving mob with tweening)

1 Like

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