How do i constantly move something without choppy movement nor tween service

i’m working on an april fool’s update for my game and i added an npc that mimicks your exact movements but there’s simply not enough frames to make it smooth. i wanna avoid tweening because while it does look funny it also looks really weird. also this is running on the client

local plr = game.Players.LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local brian = workspace.MovingBrian
local movements = {}
game:GetService("RunService").Stepped:ConnectParallel(function() --idk if there's any benefit in this case
	table.insert(movements, chr.HumanoidRootPart.CFrame)
end)
game:GetService("RunService").Heartbeat:Connect(function()
	brian:PivotTo(movements[1])
	task.wait(0.5)
	table.remove(movements, 1)
end)

Lerping it with the second parameter as delta time might work. Works for me when I need smooth stuff like that.

2 Likes

Is the issue that you’re running the second Heartbeat section with a task.wait(0.5)?

1 Like

no, because if i don’t yield then it’s way too fast.

1 Like
brian.CFrame:Lerp(movements[1], delta)

did this and nothing happened, is this right? also it’s a mesh so maybe that’s why it doesn’t work? also tried using 0.5 for the 2nd argument. i’ve never used Lerp before so i’m sorry if i’m stupid :sob:

1 Like

You have to set brains cFrame so:

brian.CFrame = brian.CFrame:Lerp(movements[1], dt)
2 Likes

Is this NPC supposed to move exactly to where your player is, even if the player is standing still?
In that case you could try making the NPC Parts CanCollide false so it doesn’t bump into you.
Otherwise you should offset the NPC’s Position a few studs away from the player’s RootPart.

Unless I’m missing something you haven’t explained yet.

My original question was due to the fact that you seem to be doing it like this:
Every Stepped you are putting this information into the table
Every Heartbeat you move the player (PivotTo)
1/2 second later you are removing the information from the table that has already been changed each Stepped from the first function.
It just seems weird to me that you aren’t doing these in one function.

2 Likes

already cancollide off

it originally was but i messed around with the code and split them into 2, i’ll use stepped and move it back in

1 Like

he uhh started spinning aggressively and he got flung.

1 Like


(Sorry for video quality)
Here are the results I got with this:

local plr = game.Players.LocalPlayer
local chr = plr.Character or plr.CharacterAdded:Wait()
local brian = workspace.MovingBrian
game:GetService("RunService").Heartbeat:Connect(function(dt)
	brian.PrimaryPart.CFrame = brian.PrimaryPart.CFrame:Lerp(chr.PrimaryPart.CFrame, dt)
end)

And an anchored HumanoidRootPart for moving brian. Might not be what u want because it’s pretty identical to tween service.
Also you can multiply dt to increase the speed of the lerp

2 Likes

it makes it looks like he’s a balloon and it’s not the effect i wanted BUT IT’S FUNNY SO I’M KEEPING IT THANKS!

2 Likes

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