Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Moving the NPC without using pathfinding?

Asked by
Yozoh 146
6 years ago

I'm creating short cutscenes like flashbacks, is there an easier way to move NPCs (with a walk animation) without using pathfinding?

I saw some tutorials that used NPC.Humanoid.MoveTo(position) etc, but it did not work (probably outdated).

2 answers

Log in to vote
0
Answered by
Amiaa16 3227 Moderation Voter Community Moderator
6 years ago

Using MoveTo is fairly simple. It takes a Vector3 as the argument and makes the character find the shortest way to the position and go towards it (note that it won't avoid obstacles)

Example:

workspace.NPC.Humanoid:MoveTo(Vector3.new(10,0,5))

You can also make it go to a part's position

workspace.NPC.Humanoid:MoveTo(workspace.Part.Position)
0
I've used that, but idk why its not working for me. I'll try again. Yozoh 146 — 6y
Ad
Log in to vote
0
Answered by
dyler3 1510 Moderation Voter
6 years ago
Edited 6 years ago

As long as your NPC contains the default ROBLOX scripts for characters, you should be able to use the WalkToPoint property of the Humanoid. For example, something like:

NPC.Humanoid.WalkToPoint = Vector3.new(10, 0, 10)

Would make your NPC walk to the point (10, 0, 10) at normal walking speed and with the animation. If you want to change the walking speed, you can just use the WalkSpeed property of the Humanoid, which defaults to 16.


Anyways, I hope this helps. If you have any further questions, let me know and I will do what I can to help.

Answer this question