the model is instantly rotate in direction that it going, I wont to make it softer/not instantly.
VIDEO
Code
local targetPosition = Vector3.new(waypoints.Position.X, 0, waypoints.Position.Z)
local StartPoint = dummy.WorldPivot.Position
local increment = (targetPosition - StartPoint).Magnitude * 2
for i = 0, 1, 1/increment do
local lerpedPosition = StartPoint:Lerp(targetPosition, i)
local lookAtCFrame = CFrame.lookAt(lerpedPosition, targetPosition)
dummy:PivotTo(lookAtCFrame, 0.1)
task.wait(0.03)
end
thanks for reply but, it doesn’t matter. The problem it’s that CFrame.lookAt() set rotation instanlty. I think I could devide it to rotate it more animation-like.
You could send that to a variable so you know the value of where it will end up. Then use that to run a tween between where it is to there. The tween can take care of the timing and smoothness.
Sounds hard but it already knows where it is … you just need to tween to where it’s going.
local targetPosition = Vector3.new(waypoints.Position.X, 0, waypoints.Position.Z)
local StartPoint = dummy.WorldPivot.CFrame
local increment = (targetPosition - StartPoint.Position).Magnitude * 2
for i = 0, 1, 1/increment do
dummy:PivotTo(StartPoint:lerp(CFrame.LookAt(StartPoint.Position,targetPosition),0.5))
task.wait(0.03)
end
local targetPosition = Vector3.new(waypoints.Position.X, 0, waypoints.Position.Z)
local dummy = -- your dummy object here
local tweenInfo = TweenInfo.new(0.5) -- adjust the time duration as needed
local tween = game:GetService("TweenService"):Create(dummy, tweenInfo, {Position = targetPosition})
tween:Play()
tween.Completed:Wait()
I’m not sure how you’re moving this NPC, so anything I say is just speculation.
If I was doing this, I would go to the toolbox add a NPC with scripts that chases you.
Probably a few … Then really look over how they are getting that done, till I find what I need.
Well you’re pretty close with that lerp … may want to keep working on that.
That tween looks like it’s updating the entire position and not just a smooth quick turn.
500 NPC’s sounds like: figure it out with a lerp in script.