Ok so whenever I fly straight up this happens
I am using an Align Orientation and it is following the players mouse if anyone has any idea why this is happening help would be greatly appreciated
Ok so whenever I fly straight up this happens
“Following players mouse” doesn’t mean much. Please post your code so we can see what it’s actually doing
Model in case you want try it and see what happens
Plane.rbxm (7.4 KB)
--~SERVICES~--
local RunService = game:GetService("RunService")
local ContextActionService = game:GetService("ContextActionService")
--~PLAYER~--
local player = game.Players.LocalPlayer
local char = player.Character
local humanoid = char.Humanoid
local root = char.HumanoidRootPart
local head = char.Head
local Mouse = player:GetMouse()
--~PLANE PARTS~--
wait()
local seat = script.Seat.Value
local Direction = seat.Direction
local Thrust = seat.Thrust
--~STATS~--
local MaxSpeed = 100
local LiftOffSpeed = 25
local MaxBank2 = 90
local RollForce = 0.01
local PitchForce = 0.2
local YawForce = 0.2
--~VARIBLES~--
local EngineOn = false
local Grounded = true
local CurrentRoll = 0
local CurrentPitch = 0
local rLeft = false
local rRight = false
local pUp = 0
local pDown = 0
local yLeft = 0
local yRight = 0
local speed = 10
local Throttle = 0
--~CAMERA~--
local camera = workspace.CurrentCamera
local function UpdateCam()
camera.CFrame = root.CFrame * CFrame.new(0, 5, 15)
end
camera.CameraType = Enum.CameraType.Scriptable
RunService:BindToRenderStep("Plane", 1, UpdateCam)
--~PLANE MOVEMENT~--
local look = Instance.new("Attachment")
look.Parent = workspace.Terrain
Direction.Attachment1 = look
Thrust.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
function GetBankAngle(M) --This function calculates the Bank Angle
local VSX,X = M.ViewSizeX,M.X
local Ratio = (((VSX/2) - X)/(VSX/2))
Ratio = (Ratio < -1 and -1 or Ratio > 1 and 1 or Ratio)
return math.rad(Ratio * MaxBank2)
end
function FlyMain()
if EngineOn == true then
if rLeft == true then
CurrentRoll = CurrentRoll + RollForce
end
if rRight == true then
CurrentRoll = CurrentRoll -RollForce
end
local BankAngle = GetBankAngle(Mouse)
look.CFrame = Mouse.Hit*CFrame.Angles(0,0,BankAngle)*CFrame.Angles(PitchForce*(pUp+pDown),YawForce*(yLeft+yRight),CurrentRoll)
Thrust.Velocity = seat.CFrame.LookVector * speed
end
end
function Rotate(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.Begin then
if actionName == "RollLeft" then
rLeft = true
elseif actionName == "RollRight" then
rRight = true
elseif actionName == "PitchDown" then
pDown = -1
elseif actionName == "PitchUp" then
pUp = 1
elseif actionName == "YawLeft" then
yLeft = 1
elseif actionName == "YawRight" then
yRight = -1
end
end
if inputState == Enum.UserInputState.End then
if actionName == "RollLeft" then
rLeft = false
elseif actionName == "RollRight" then
rRight = false
elseif actionName == "PitchDown" then
pDown = 0
elseif actionName == "PitchUp" then
pUp = 0
elseif actionName == "YawLeft" then
yLeft = 0
elseif actionName == "YawRight" then
yRight = 0
end
end
end
function TurnEngineOn(actionName, inputState, inputObject)
if inputState == Enum.UserInputState.End then
if EngineOn == false then
EngineOn = true
else
EngineOn = false
end
end
end
ContextActionService:BindAction("RollLeft", Rotate, true, Enum.KeyCode.A)
ContextActionService:BindAction("RollRight", Rotate, true, Enum.KeyCode.D)
ContextActionService:BindAction("PitchDown", Rotate, true, Enum.KeyCode.W)
ContextActionService:BindAction("PitchUp", Rotate, true, Enum.KeyCode.S)
ContextActionService:BindAction("YawLeft", Rotate, true, Enum.KeyCode.Q)
ContextActionService:BindAction("YawRight", Rotate, true, Enum.KeyCode.E)
ContextActionService:BindAction("TurnEngineOn", TurnEngineOn, true, Enum.KeyCode.Y)
--ContextActionService:BindAction("ThrottleUp")
RunService.Heartbeat:Connect(function() FlyMain() end)
humanoid.Seated:Connect(function(isSeated, seat)
if not isSeated then
RunService:UnbindFromRenderStep("Plane")
camera.CameraType = Enum.CameraType.Follow
Thrust.Velocity = Vector3.new(0,0,0)
Thrust.MaxForce = Vector3.new(0,0,0)
look:Destroy()
end
end)
Mouse.Hit
will never have an UpVector that has a negative Y component, so there’s no way your current solution can allow players to fly upside down. Is that what you’re trying to do?
Yea I guess that might be the reason its freaking out when I fly straight up
So is there anyway I can make it so you can fly up around in a loop?
You have any ideas on what I could do to fix this
Sending another message too renew this post cause I am still having this issue
You could get the unit vector between the Hit
and the player, and possibly do something with that.
I don’t understand what you are suggesting I do I need a CFrame to align it properly
Refreshing this issue again the issue appears to be that Mouse.Hit cannot have a UpVector that has a negative Y so if anyone knows how to fix this it would be greatly appreciated
Right now your approach depends on that quality of mouse.Hit
to keep the plane upright. So if you want an approach that doesn’t depend on that because you want to allow the player to fly upside down, you’ll have to decide how you want to handle which way the UpVector of the plane is pointing. There’s lots of ways that could be done, so it’s easier to help if you can give a description or example of how you actually want the plane to control.
Sorry for late response but I just want it to be Mouse Movement so any way that I can get the mouse to control the plane and if that’s not descriptive enough for you could you list a few ways so I can go and test them myself to see if they work