Hi, I’m working on a project and attempting to create a mouse guided plane using the method shown below:
I’m just wondering if anyone has any suggestions on where I can begin?
I understand I’m going to be using BodyMovers for this guided by the UserInput, but how can I gather the required data in order to:
Make it turn / bank in accordance with the mouse.
Make it rotate on the Z Axis so it’s capable of going upside down.
I know the best bet is using a VehicleSeat & getting information from the .Steer and .Throttle but does anyone else have any other suggestions?
Your roll should be proportional to your jaw for it to look realistic.
An easy way of doing it is check the angle difference between your last velocity vector and your current one.
local difference = math.acos(lastVelocity.unit:Dot(currentVelocity.unit))
Then roll your ship accordingly:
local roll = difference * ROLL_STRENGHT --ROLL_STRENGHT can be any number, it's how much you want to roll.
ship.CFrame = ship.CFrame * CFrame.Angles(roll, 0, 0)
Note: Depending on your setup, you might have to do CFrame.Angles(0, roll, 0) or CFrame.Angles(0, 0, roll) instead.
Here’s some code I wrote for a project that does what you want. The plane is controlled by the mouse, the plane can do loops. local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local character = player.Character
local plane = character.Plane
local characterRoot = character.HumanoidRootPart
local planeBase = plane:FindFirstChild(“PlaneBase”)
local planeBaseWeld = planeBase:FindFirstChild(“Weld”)
local planeBaseWeld2 = planeBase.Weld
local planeWings = plane:FindFirstChild(“Wings”)
local planeWingsLeft = planeWings:FindFirstChild(“Left”)
local planeWingsRight = planeWings:FindFirstChild(“Right”)
local planeWingsLeftWeld = planeWingsLeft:FindFirstChild(“Weld”)
local planeWingsRightWeld = planeWingsRight:FindFirstChild(“Weld”)
local planeTail = plane:FindFirstChild(“Tail”)
local planeTailWeld = planeTail:FindFirstChild(“Weld”)
local planeTailWeld2 = planeTail.Weld
local function controlPlane()
local planeBaseCFrame = planeBase.CFrame
local planeBaseCFrame2 = planeBaseCFrame + planeBase.CFrame.lookVector * 0.01
local planeBaseCFrame2 = planeBaseCFrame + Vector3.new(0, 0, 0)
local planeBaseCFrame2 = planeBaseCFrame + planeBase.CFrame.rightVector * -mouse.X / 100
local planeBaseCFrame2 = planeBaseCFrame + planeBase.CFrame.upVector * -mouse.Y / 100
local planeBaseCFrame2 = planeBaseCFrame * CFrame.Angles(0, 0, 0)
local planeBaseCFrame2 = CFrame.new(planeBase.Position.X - mouse.X / 100, planeBase.Position.Y - mouse.Y / 100, planeBase.Position.Z)
local planeWingsCFrame = planeWingsRight.CFrame
local planeWingsCFrame2 = planeW