Gradually increase tween service speed

What am I trying to do?
I’m trying to get the object to gradually move faster as it hits the part and not jolt into a faster speed, I’ve moved each point further out than the last to make it faster.

local TweenService = game:GetService("TweenService")
local plane = script.Parent
local one = {
Position = game.Workspace.one.Position;
Orientation = game.Workspace.one.Orientation
}
local two = {
Position = game.Workspace.two.Position;
Orientation = game.Workspace.two.Orientation
}
local three = {
Position = game.Workspace.three.Position;
Orientation = game.Workspace.three.Orientation
}
local four = {
Position = game.Workspace.four.Position;
Orientation = game.Workspace.four.Orientation
}
local five = {
Position = game.Workspace.five.Position;
Orientation = game.Workspace.five.Orientation
}
local six = {
Position = game.Workspace.six.Position;
Orientation = game.Workspace.six.Orientation
}
local seven = {
Position = game.Workspace.seven.Position;
Orientation = game.Workspace.seven.Orientation
}
local eight = {
Position = game.Workspace.eight.Position;
Orientation = game.Workspace.eight.Orientation
}

	local tweenInfo = TweenInfo.new(10, Enum.EasingStyle.Linear,Enum.EasingDirection.InOut,- 0,false,0)
	local anim = TweenService:Create(plane, tweenInfo, one)
	anim:Play()
	anim.Completed:wait()
	local anim = TweenService:Create(plane, tweenInfo, two)
	anim:Play()
	anim.Completed:wait()
	local anim = TweenService:Create(plane, tweenInfo, three)
	anim:Play()
	anim.Completed:wait()
	local anim = TweenService:Create(plane, tweenInfo, four)
	anim:Play()
	anim.Completed:wait()
	local anim = TweenService:Create(plane, tweenInfo, five)
	anim:Play()
	anim.Completed:wait()
	local anim = TweenService:Create(plane, tweenInfo, six)
	anim:Play()
	anim.Completed:wait()
	local anim = TweenService:Create(plane, tweenInfo, seven)
	anim:Play()
	anim.Completed:wait()
	local anim = TweenService:Create(plane, tweenInfo, eight)
	anim:Play()
	anim.Completed:wait()

U need to change the Easing Style and Easing Direction

I will try this in the morning.

How would changing direction and style make it gradually increase speed?

In your tweenInfo variable, you are able to change the easingstyle with Enum.EasingStyle and Enum.EasingDirection.

Currently, you are setting it to Linear and InOut. My personal suggestion for making it gradually get faster would be using the Quad easingStyle.

You can read more about EasingStyles here.

What I mean is that, for example, when the object hits part six, it jolts immediately faster because part seven has more of a gap between part six and seven and part 5 and 6 has a smaller gap so it basically takes 10 seconds for both the gaps which I want but I want a smooth transition not a jolt of speed.

You can either use an Exponential, Quad, Quart, Quint, Circular, or Sine easing style to achieve this.

1 Like

This should explain the situation I am in.
https://gyazo.com/3ffcdf38a854f7c9a9241782b5f50e96

2 Likes

I see

You want flow between the tweens. That is tricky, verrrrry tricky. If you had 2 tweens, you could probably do it after some tinkering.

But 6. Good luck. You are better off tweening them yourself (which is also difficult, but actually feasible unlike TweenService’s method). If you want to know why you can’t get a good combination with 3 or more tweens, just look at the GIF here from the dev hub:

If you want to use one tween, you go with InOut since it starts and stops.
If you want to use two tweens, you start with In, and end with Out.
If you want to use three tweens, haha you can’t - Out is the only one that can continue from In (the first one), but Out is also an ending tween direction - so you can’t make it smooth into the next tween which you might want to have some initial speed.

I know boatbomber made BoatTween recently, but I’m not sure it would resolve your issue, either (unless you made your own easing style, which probably would amount to making your own tween altogether - but hey, what do I know). It might be worth looking into (I’ve never used it so I can’t really say myself how doable it is, although it is definitely more powerful than the standard TweenService).

The most crude way to do it is to predefine every frame of movement (much like you would in a complex animation, which really is the essence of what you are trying to accomplish). That means, having a table of data specifying how much the plane’s position should change every frame. So for example, something like this:

local counter = 0
game:GetService("RunService").Heartbeat:Connect(function()
    Plane.Position = Plane.Position + data[counter]
    counter = counter + 1
    if counter > 120 then counter = 0 end -- (120 frame tween)
end)

You would also have to take into account orientation (or else you might get sideway motion or something) so you would have to adjust data to be rotated in the direction of your plane. This to me feels a lot more powerful (you have control of every frame) but is MUCH more prone to error. Also uses more memory because it’s no longer interpolated :slight_smile:

But for complex paths, there isn’t always a simple equation or easing style to get the job done.

3 Likes

Thank you for spending your time with that response! Much appreciated, I’ll use your response to figure out something hopefully.

1 Like