Bit of a steep one, how would I interpolate / blend tweens together?

TL;DR - How can I make it so that if I play a tween while one is already playing, instead of canceling out the currently playing tween it “blends” them together?

Alright, little bit of context here.

I am trying to animate the landing gear of an airplane. There’s some specific mechanisms here at play, it’s motor6D, and I can’t just have every part of it retract with 1 tween, as parts will need to shift around a bunch.

Now, I thought “what if I played the next tween as the previous one was playing?” thinking that it was gonna “smooth out”, but turns out… It cancels out the tween that’s currently playing.

How can I make it so that instead of canceling out it “blends” the 2 tweens together? (As some sort of transition I guess?)

Here’s a picture of the landing gear, highlighted parts are the pivots for the motors.
image

Using :Lerp() and TweenService:GetValue(alpha: number,easingStyle: Enum.EasingStyle,easingDirection: Enum.EasingDirection):number

It calculates a new alpha given an Enum.EasingStyle and Enum.EasingDirection.

1 Like

…Well that’s definitely something I will have to brain out on how to setup.

Ah, forgot to clarify here uh… I am kinda tweening the DesiredAngle, I suppose I should probably switch to C0 for this one?

Oh, and, possibly a little snippet of the thing. (supposed to be a temp script…)

Tween info is:

local GearTI = TweenInfo.new(4,Enum.EasingStyle.Quad,Enum.EasingDirection.InOut)

Actual tweens (that are contained in a function) are:

TweenService:Create(FG,GearTI,{DesiredAngle = math.rad(AnimationTimelines.Up1.FG)}):Play()
TweenService:Create(FGR1,GearTI,{DesiredAngle = math.rad(AnimationTimelines.Up1.FGR1)}):Play()
TweenService:Create(FGR2,GearTI,{DesiredAngle = math.rad(AnimationTimelines.Up1.FGR2)}):Play()
task.wait(3)
TweenService:Create(FG,GearTI,{DesiredAngle = math.rad(AnimationTimelines.Up2.FG)}):Play()
TweenService:Create(FGR1,GearTI,{DesiredAngle = math.rad(AnimationTimelines.Up2.FGR1)}):Play()
TweenService:Create(FGR2,GearTI,{DesiredAngle = math.rad(AnimationTimelines.Up2.FGR2)}):Play()
task.wait(3)
TweenService:Create(FG,GearTI,{DesiredAngle = math.rad(AnimationTimelines.Up3.FG)}):Play()
TweenService:Create(FGR1,GearTI,{DesiredAngle = math.rad(AnimationTimelines.Up3.FGR1)}):Play()
TweenService:Create(FGR2,GearTI,{DesiredAngle = math.rad(AnimationTimelines.Up3.FGR2)}):Play()

You might want to consider just using an animation if you’re doing a complicated animation. Just add an animation controller on the server, name each part something unique (I think you need to do this at least), rig it up with motor6s, use the animation editor to make the animation, and then play it by loading the animation on the controller then using the :Play() function.

Using Animations: Non-Humanoids | Documentation - Roblox Creator Hub

It should only cancel the tween if you’re trying to tween the same motor6 twice. Would it be possible to either: add a second motor6 there so it’s basically a double joint (then use separate tweens for each motor6) or just split the animation for the single motor6 into two tweens that don’t overlap?

If you want to have tweens that go over each other, you’ll generally need three things:

  • A first movement tween
  • A second movement tween
  • A weight value (for lerping between)
  • A tween to move the weight (or do it manually just like a tween would)

Here’s an example:

local targetInstance -- Your Instance
local propertyName -- The property name, probably C1 or C0

local target1Value = Instance.new("CFrameValue")
local target2Value = Instance.new("CFrameValue")
local weight = Instance.new("NumberValue")

-- Whatever your two tweens are
local tween1 = TweenService.Create(target1Value, TweenInfo.new(1), {Value = [Your Target]})
local tween2 = TweenService.Create(target2Value, TweenInfo.new(1), {Value = [Your Target]})

-- Customize the tween info to change how it fades between the stuff
local weightTween = TweenService:Create(weight, TweenInfo.new(1), {Value = 1})

local updateConnection
updateConnection = RunService.Heartbeat:Connect(function()
    targetInstance[propertyName] = target1Value.Value:Lerp(target2Value.Value, weight.Value)

    -- End the connection if all the tweens are done playing
    if tween1.PlaybackState ~= Enum.PlaybackState.Playing and tween2.PlaybackState ~= Enum.PlaybackState.Playing and weightTween.PlaybackState ~= Enum.PlaybackState.Playing then
        updateConnection:Disconnect()
    end
end)
tween1:Play() -- Start your first animation

task.wait(1) -- Whatever the delay is for your second tween

tween2:Play()
weightTween:Play() -- Starts fading from tween1 to tween2