How can I make model rotate not instantly?

ISSUE

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

I’m happy to hear any help!

3 Likes

A bit too fast … Try a bit longer. ( you know I’m going to say 0.33, right )

1 Like

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.

1 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.

1 Like

how do I tween it? Cuz it’s model

1 Like

Use lerp.

				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

Should work.

1 Like

This may need some love …

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()

lerp will work also.

1 Like

dude it cause alot of problems… invalid argument #2 (Vector3 expected, got CFrame)

1 Like

Dude it’s MODEL, not part, so it doesn’t have “Position” property.

2 Likes

I’m pretty sure moving the HumanoidRootPart of a char will rotate the whole thing, because it’s the primarypart of the model

2 Likes

StartPoint.PrimaryPart … maybe as long as that is set to the root.

2 Likes

no, it’s cause very weird problems.

2 Likes

Maybe you know some one do divide CFrame.LookAt?

2 Likes

I tried to tween it but now what happens…

He just move straight

2 Likes

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.

1 Like

You know where the problem, ofc I could just add humanoid to the NPC and write:

    Humanoid:MoveTo(Waypoint.Position)

Put customer said me that it cause a huge lags (because he need around 500 npcs)

1 Like

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.

1 Like

Okay, thank you for your reply.

2 Likes

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