Aircraft glitching at high speeds or low FPS

I am currently developing an aircraft combat game, and working on the physics.
The aircraft is moved via vector forces (thrust, lift, drag), where each airfoil (wing component) calculates its own lift and drag forces.
These aerodynamic forces are updated via the client’s RunService.Hearteat function.

I am having an issue, where if the aircraft gets to high speeds, or the client has low FPS, the aircraft glitches, and the forces break.

I have tried both including and excluding delta time in different areas to change the resultant forces, and nothing stops the issue from occurring.

Here is a video of the issue at 165 frames per second. You can see when we get to high speed, the aircraft glitches.

robloxapp-20230601-1918369

I had the same issue, personally found using a physics substep algorithm did the trick to stabilize more at lower fps:

Got the idea from also a unity tutorial on aircraft haha:

--Calculate force normal, used in vector forces
        local upwardForce = calculateForces(targetHeight, currentHeight, currentYVelocity, t, mass, hipHeight, dt)

        local function physicsSubstep(substepUpwardForce, step, substepYVelocity, iterateHeight)
            local netForce = substepUpwardForce  - weight

            local predictedVelocity = predictVelocity(netForce, mass, substepYVelocity, step)
            local predictedDisplacement = predictDisplacement(netForce, mass, substepYVelocity, step)

            local newUpwardForce = calculateForces(targetHeight, iterateHeight+predictedDisplacement, predictedVelocity, t, mass, hipHeight, dt)
            local averageVelocity = (substepYVelocity+predictedVelocity) * 0.5
            local averageForce = (newUpwardForce+ substepUpwardForce)*0.5
            local averageHeight = iterateHeight+predictedDisplacement*0.5

            return averageForce, averageVelocity, averageHeight
        end

        --Perform physics substep
        local iterateForce = upwardForce
        local iterateYVelocity = currentYVelocity
        local iterateHeight = currentHeight
        local n = 3 --Split a frame into multipe "Substep" frames
        local step = dt/n
        for _ = 1, n-1 do
            iterateForce, iterateYVelocity, iterateHeight = physicsSubstep(iterateForce, step, iterateYVelocity, iterateHeight)
        end
        upwardForce = iterateForce

Scenario for stiff spring suspension on a custom character:

Before:

After:

3 Likes

Lol, I used the exact same video when making the physics for my game XD. I removed the torque idea, however I also didn’t add the prediction functions, as I didn’t know how to implement them properly, but looking at things, I think that might be the issue then.

1 Like

I was trying to find other potential problems, and I only just realised that the lift force I apply for each airfoil DOESN’T take in the aircraft’s mass. Is this something it should do?