Lerping Objects

Hello developers, today I need some assistance,

I have a camera and a model, both of which move along a path. Currently, I have them going from point to point like so

But this jerks too much, as the camera and model both change direction instantly at each point. What I really need though, is something more like this:

If anyone here has a simple system which can tell an object where it should be in this sort of lerping system (4 parts), or can tell me how to go about making a simple one, I’d greatly appreciate it!

Check out this Bezier Curves wiki article. If you familiarize yourself enough with them, you can make some super great curvy-smooth trails.

Also, be sure to pronounce it properly. I didn’t for like a year:

1 Like

That helps a lot! I’m not entirely sure how to utilize this code, though. I have a localscript and a module, the localscript containing this:
image
and the module script containing the 2nd to last large code snip (for the module) towards the end of that wiki article.

Do I go through a loop of 0 to 1 (for t) for each part in my curve table, and position the camera/model with what it returns?

“Beh-zz-eer curve”

For the camera, you could use interpolate. Not sure how that would work for the model though

Find a smooth path between a set of points

The easy way is Catmull-Rom. It’s as simple as it gets and the results usually look good enough. Here’s discussion on how to implement it.

Natural splines are harder to pull off but they give the smoothest possible curves, i.e. minimizing the square of acceleration. The solution for n points is a pain to implement, but there might actually be a nice solution for just 4 points.

1 Like

Not speaking for Roblox, but avoid using Interpolate for new work. Use TweenService instead.

@AllYourBlox might have thoughts on this.

Is there a new method for :Interpolate, or is it going to be removed?

How come it’s not marked as deprecated on the wiki? Your comment makes it seem like they’re about to remove the method

1 Like

It’s not officially deprecated yet, as there is no replacement. But it will be when the new Lua camera controllers ship in 2018 with interpolation incorporated. He’s giving you an early heads up. Camera:Pan and Camera:Tilt will also be removed as C++ API calls, replaced with Lua code. Camera:Roll will be supported a bit longer, on account of it being more widely used. There is simply no reason to have camera control code partly in C++, partly in Lua. We want it all in Lua. My end goal is for the C++ Camera object to be little more than a CFrame and FieldOfView.

3 Likes

Not speaking for Roblox, but avoid using Interpolate for new work. Use TweenService instead.

Do note that you cannot tween a model. I’ve run in to this problem a few times. You either have to use lerp (which looks framey IMO) or some sort of bodymover.

I’ve been messing around with the code, but I can’t quite figure out what exactly I’m supposed to hand to the “travelPath” function inside my script. Currently, I have a local script which looks like this:

and a module script inside of it which looks like this

Does anyone know how to properly use travelPath? The wiki explains it a little but it gets confusing about halfway through the article.