Self-Flying Plane Tweening Question

Hey! I’m trying to create a self-flying plane. This will later on be able to have passengers in it. The plane has a fakepart which is being tweened to the next waypoints/checkpoints, then every frame the plane is being cframed to the fakepart (to make it possible to stand on the plane using this)

As you most likely know, a plane accelerates and decelerates. Now, obviously if the plane is keeping a constant speed I’m using Enum.EasingStyle.Linear and Enum.EasingDirection.Out. I’ve been experimenting with several easingstyles and easingdirections to make it seem like the plane is accelerating and/or decelerating. To accelerate I’ve used Quad and In, to decelerate I’ve used Quad and Out. Sadly this doesn’t work that well, as it stops all speed at the waypoints and then accelerates again.

I would like to know how to make sure it doesn’t stop at the waypoints, while making it seem like the plane is accelerating and decelerating when using tweens.

4 Likes

local tweenService = game:GetService( "TweenService" ) --Get the tween service.

02

03 local part = Instance.new( "Part" ) --Make a new part.

04 part.Position = part.Position --ignore

05 part.Anchored = true --Part is anchored.

06 part.Parent = game.Workspace --The parent of the part is workspace

07

08 local goal = { } --Table.

09 goal.Position = Vector 3. new(x,y,z) --Where you want the part to go (world coordinates) (change x y z to coordinates)

10

11 local tweenInfo = TweenInfo.new( 4 ) --Speed (The lower the number the fastest the tween)

12

13 local tween = tweenService:Create(part, tweenInfo, goal) --Give the tween info.

14

15 tween:Play() --Execute the tween.

I’m not using bodyforces because I want to be able to control the speed of the plane. I fully understand how tweens work and how to create them. Thank you for replying though.

1 Like

The easy answer for acceleration/deceleration is probably Enum.EasingStyle.Sine, but if you’re able to I’d maybe just make more waypoints in some areas and that way you can create tweens with increasing/decreasing speeds to sort of create an illusion.

As for making it as seamless as possible, I’d do something like

local Waypoints = {...}

for i = 1, #Waypoints do
    local Point = Waypoints[i]
    local Tween = TweenService:Create(...)
    Tween:Play()
    Tween.Completed:Wait()
end
1 Like

You can formar code better by doing

```Lua
print('Hello world!')
`` `

(remove that space in the last `)

1 Like