of     1   

marfit
#183617731Sunday, February 14, 2016 10:07 PM GMT

I am making an airport and I want to have like a smoothly moving "train" that goes back and forth between the entrance and terminal. How do I do this?
nicemike40
#183618001Sunday, February 14, 2016 10:10 PM GMT

For a train you could probably get away with exploiting ROBLOX physics, rather than hard-coding something with CFrame or something like that. i.e. change the Velocity property of the tracks, or maybe use a BodyVelocity/Force/Position object, or have actual wheels that roll.
marfit
#183618109Sunday, February 14, 2016 10:11 PM GMT

How do I do the hard coding. I don't use velocity and friends.
nicemike40
#183618673Sunday, February 14, 2016 10:19 PM GMT

Well, then it depends. Basic principle to move the whole model is with model:TranslateBy(Vector3) or model:SetPrimaryPartCFrame(CFrame). I recommend the latter, since you have finer control over where exactly the train is. How you want to handle smoothly moving it is up to you, but the basic principle is: local function LerpModelTo(model, endCFrame, time) local startCFrame = model:GetPrimaryPartCFrame(); local startTime = tick(); while true do local a = (tick()-startTime)/time; if (a>1) then break; end model:SetPrimaryPartCFrame(startCFrame:Lerp(endCFrame, a)); wait(); end model:SetPrimaryPartCFrame(endCFrame); end , and then to call that when you want to move the model. There's fancier stuff you can do to allow the animation to be interrupted, to base it off of speed rather than time, etc. but I'll leave that as an exercise for the reader lol
Lord_Narwhal
#183618784Sunday, February 14, 2016 10:21 PM GMT

wait, you can smoothly move bricks without using for loops? #Code print("Narwhals are our future")
marfit
#183618812Sunday, February 14, 2016 10:21 PM GMT

I have no dang idea what that does, mind formatting it with easier to read things like TRAVEL TO (Position) and DIRECTION (x,y,z)
nicemike40
#183619096Sunday, February 14, 2016 10:25 PM GMT

Also make that Lerp lowercase, mb. I'm working on an example gimme a second.
nicemike40
#183619846Sunday, February 14, 2016 10:37 PM GMT

Here: http://codepad.org/LbQDywuj I added a 'keepOrientation' option, plus a bit of documentation and an example.
marfit
#183621273Sunday, February 14, 2016 10:58 PM GMT

Nice how do I edit how long it takes? Where do I do that?
marfit
#183621358Sunday, February 14, 2016 10:59 PM GMT

And keep orientation.
marfit
#183622154Sunday, February 14, 2016 11:10 PM GMT

I figured time out but not orientation I want it to keep it's orientation.
marfit
#183622649Sunday, February 14, 2016 11:16 PM GMT

Mike how do I change the keeporitenation?
pinballboy7
#183622677Sunday, February 14, 2016 11:17 PM GMT

CFrame + lerping

    of     1