I’m working on a flight system as linked below - I currently have a bumpy / rigid effect when trying to fly behind the Player.
https://gyazo.com/96157a2c6530bbf393536073792d7547
I initially thought that using Mouse.Hit.p was the issue so I remade it using UserInputService and converting 2D to 3D. However the issue still occurs when attempting to fly behind.
Does anyone have any suggestions? I’m looking for it to just rotate accordingly and smoothly.
function Core:LookAt(Base, ...)
Base = self.Base
local MousePos = Core:GetMousePos(...)
local OriginCF = self.AlignOrientation.CFrame
local Size = Base.Size
local Target = Base.Position + ((MousePos - Base.Position).unit * 100)
local Dir = (Target - Base.Position).unit
local SpawnPos = Base.Position
local Left = Base.CFrame * CFrame.new(-Size.X / 2, 0, 0).Position
local Right = Base.CFrame * CFrame.new(Size.X / 2, 0, 0).Position
local Mid = (Target - Base.Position).Magnitude
local Foebmd = Base.CFrame * CFrame.new(0, 0, -Mid).Position
local ToLeft = (Target -Left).Magnitude
local ToRight = (Target -Right).Magnitude
local Rot = ((Foebmd - Target).Magnitude / 10)
local Pos = SpawnPos + (Dir * 1)
local Turn = math.rad((Rot / 10) * 40)
if Turn > math.rad(89) then
Turn = math.rad(89)
end
if ToLeft < ToRight and ToLeft > Rot then
self.AlignOrientation.CFrame = CFrame.new(Pos, Pos + Dir) * CFrame.fromEulerAnglesXYZ(0, 0, Turn)
elseif ToLeft > ToRight and ToRight > Rot then
self.AlignOrientation.CFrame = CFrame.new(Pos, Pos + Dir) * CFrame.fromEulerAnglesXYZ(0, 0, -Turn)
else
self.AlignOrientation.CFrame = CFrame.new(Pos, Pos + Dir)
end
end