Trying to understand how I can create a somewhat simple airplane and I’m using BodyVelocity and BodyGyro. I constantly rotate the BodyGyro towards the mouse’s hit position and update the BodyVelocity’s Velocity to plane.PrimaryPart.CFrame.LookVector * plane.Throttle
. Though I’m getting very odd results using this method as seen here:
The BodyGyro just doesn’t seem to rotate towards the mouse properly and then corrects its position a few seconds after. This always happens and I don’t know what is causing it. Here’s my code:
-- LocalScript
game:GetService("RunService").RenderStepped:connect(function()
game.ReplicatedStorage.tiltPlane:FireServer(mouse.Hit.p, mouse.Hit.LookVector)
end)
-- ServerScript
game.ReplicatedStorage.tiltPlane.OnServerEvent:Connect(function(player, mouseHitP, mouseLookVector)
local seat = player.Character.Humanoid.SeatPart
if seat == nil then return end
local model = seat.Parent
local plane = getPlane(model)
plane.model.PrimaryPart.BodyGyro.CFrame = CFrame.lookAt(plane.model.PrimaryPart.Position, mouseHitP)
plane.model.PrimaryPart.BodyVelocity.Velocity = plane.model.PrimaryPart.BodyGyro.CFrame.LookVector * plane.Throttle
end)