How would I move a part very smooth without Lerping or Tweening?

Hello, I am trying to make a Cable Sag system for my game. Now lets cut to the thing, I am currently trying to make the part that moves go very smoothly with a speed but without using Lerping or Tweening, the cause because I can not use Lerping or Tweening is that Tweening cannot slow down well and Lerping will bug when I am trying to move it from part to part using a for loop. And Tweening cannot slow down until it gets to the next part unless you make code that seems not needed. Anything helps, thanks!

1 Like

You are always exactly limited by your game’s heartbeat [/stepping] speed (see here for deeper explanation). You would want to basically iterate your property changes around one of these three events (Heartbeat, RenderStepped, or Stepped – depending on circumstances).

  • RenderStepped [:BindToRenderStepped() method of RunService] - occurs before a frame renders
  • Stepped [RunService.Stepped:Wait()\Once()] - occurs before internal physics step only
  • Heartbeat [task.wait() (or unidiomatically RunService.Heartbeat:Wait()\:Once())] - occurs as the final computing step of task scheduler, followed only by occasional replication packets sendoff

You would want to run small math per iteration on one of these occurrences in your loop. This is, by the way, all that TweenService and Lerping does. Only difference being that these methods are in private Roblox Luau modules (afaik it would be Luau, given that they have attached metatables).

So basically, to conclude, you would want to use the distance between the parts for some basic setup - get the unit vector of the magnitude between the two parts, get both full vectors of both parts, then depending on your goal iterate using the unit vector multiplied by some amount to be assured that you reach your goal upon the for loops conclusion; although you could avoid some extra math using a different loop (while) instead!

Hope this helps :slight_smile:

1 Like

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