Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

How can I make my train go around tracks smoothly?

Asked by 4 years ago
Edited 4 years ago

Hi, so I have my train which works, but it looks weird when its moving. It has a pause in between the nodes and it doesn't go very smooth.

Video: https://streamable.com/1wbhua

My Code:

local RunService = game:GetService("RunService")

local node = 0

function movemodel(model,start,End,AddBy)
    for i = 0, 0.5, 0.01 do
        if not model.PrimaryPart then break end
        model:SetPrimaryPartCFrame(model.PrimaryPart.CFrame:lerp(start.CFrame, i))
    RunService.Heartbeat:Wait()
    end
end

while true do
    local nextnode = game.Workspace.Nodes:FindFirstChild(node + 1)
    local End = game.Workspace.Nodes:FindFirstChild(node + 2)
    node = node + 1
    movemodel(script.Parent,nextnode,End)
end
0
This is a hard thing to pull off . for exemple jailbreak managed to pull it off in 2018 wich is insane amaizing_01 0 — 4y
0
I already did it, i just wanna know how to slow down the lerps Itzlewis99 26 — 4y
0
I don't have any specific code, but on twitter, I saw Egomoose post an example and say he was using timing sequences of some sort. JasonTheOwner 391 — 4y
0
Send me the tweet link pls Itzlewis99 26 — 4y
0
You should use tween service for the train, its more what your looking for marine5575 359 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

What happens when you take out the Wait?

Try removing this line:

 RunService.Heartbeat:Wait()

But in removing the wait, it probably will go too fast...

To get smooth motion, at a reasonable speed, I think the use of align constraints and physics may be the way to go, instead of cframing..... I saw an example on the dev forum that I'll try to find for you, today.

0
It just goes straight to the end if i remove it Itzlewis99 26 — 4y
Ad

Answer this question