I have the perfect solution NTAB:
What I would do is every RenderStep, calculate the Dot between: lastStepAirplaneLookVector and currentStepAirplaneLookVector.
(Excuse the unformatted code, I’m on my phone lol)
function renderStep()
local currentStepAirplaneLookVector = plane.CFrame.LookVector
local dot = lastStepAirplaneLookVector and lastStepAirplaneLookVector:Dot(currentStepAirplaneLookVector)
lastStepAirplaneLookVector = currentStepAirplaneLookVector
end
Then, rotate the airplane by doing:
local rollAngle = (1 - dot) * rotateIntensity
However, this will roll the airplane in only one direction, regardless of which direction the airplane is turning.
We will need to add one more thing to make sure it rolls in the correct direction:
local _, currentY = currentStepAirplaneLookVector:ToEulerAnglesYXZ()
local _, lastY = lastStepAirplaneLookVector:ToEulerAnglesYXZ()
local rollDirection = math.sign(currentY - lastY)
Ok, we finally have everything we need!
function renderStep()
local currentStepAirplaneLookVector = plane.CFrame.LookVector
local dot = lastStepAirplaneLookVector and lastStepAirplaneLookVector:Dot(currentStepAirplaneLookVector) or 1
local _, currentY = currentStepAirplaneLookVector:ToEulerAnglesYXZ()
local _, lastY = lastStepAirplaneLookVector:ToEulerAnglesYXZ()
local rollDirection = math.sign(currentY - lastY)
local rollAngle = (1 - dot) * rotateIntensity * rollDirection
lastStepAirplaneLookVector = currentStepAirplaneLookVector
end
You may have to do some adjusting of which angle to use, for example you may need to get difference of the X or Z angles instead of the Y angles, and you might need to multiply the rollDirection by -1 if the direction the plane rolls in is flipped - I’m only saying this cause I’m on my phone and haven’t tested any of this, but it should work