The issue
So I got this truck that I want to move around ingame by script, not player controlled.
Right now I do RenderStepped:connect and lerp the trucks engines CFrame around.
The other parts are attached by Motor6D instead of welds to make sure they move along.
Some parts I even custom set the velocity to inorder to make sure you can stand on the truck roof for example.
I feel like this puts alot of effort on renderstepped, especially when I do similar treatment for alot of moving parts.
Is there a better way to do this?
I can’t have laggy visuals
Some parts, atleast, must have realistic velocity
It can’t be run by BodyGyro and BodyPosition/Velocity - That stuff always glitches no matter how much you configure it.
RenderStepped blocks the pipeline until it is complete, while Heartbeat/Stepped run in parallel with rendering so it is more efficient to do your logic there. These methods all have the same frequency. (once per frame) If you’re syncing something up to the player’s camera, use RenderStepped, otherwise Stepped/Heartbeat is usually best practice.
The difference between Heartbeat/Stepped is that Stepped runs right after animations are updated and right before physics, while Heartbeat runs right after physics updates.
If I were going to do this, I’d use TweenService, updating maybe 15x per second.
The movement won’t look laggy, although it wouldn’t go perfectly along whatever line you have. I doubt it’s very noticeable, and this would move a lot of the lerping work onto the C side which I’d image is more efficient. I haven’t tested this, so I could be completely wrong
You could try to update velocity on heartbeat like you were doing, and position it with TweenService?
That might take some stress off the lua end, while still allowing you to stand on the truck.