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

Walking a certian distance towards player target?

Asked by 8 years ago
script.Parent.Humanoid:MoveTo(Target.Value.Character.Torso.Position , Target.Value.Character.Torso)

How can I make it so it only goes say, half way towards the target?

1 answer

Log in to vote
1
Answered by 8 years ago

The trick is to only make it move towards the midsection. For this I'll use lerp so that you can reasonably change the fraction of the distance it covers.

script.Parent.Humanoid:MoveTo(Target.Value.Character.Torso.Position:lerp(script.Parent.Position, 0.5) , Target.Value.Character.Torso)

I'm not sure whether you want the second argument in this case, but I've kept it because I don't have the context of your application.

0
^ when I do that the npc moves with my turns like I turn right and he turns right, is there anyway for him to just follow me at a distance QuantumToast 261 — 8y
0
Yeah that's why I said you probably don't want the second argument. The issue is of course that now you're talking about having a distance restraint which is a totally different ordeal. User#6546 35 — 8y
Ad

Answer this question