Hey everyone.
I’ve been stuck on this issue for weeks with no real solution to fixing the problem.
It has heavily blocked my progress on my current game. DISCLAIMER: TO RECREATE THE ERROR, YOU MUST FLY THE SHIP AROUND FOR A BIT, THEN IT’LL HAPPEN AFTER A FEW SECONDS OF FLYING.
To put it short, I’ve got a flying system. It flies perfect at first (example video:)
Then, as seen in this video, it messes up and flies wrong.
Here’s the place files if someone could have a look around and figure out what’s actually going wrong.
Flying code is found in the a LocalScript in StarterPlayerScripts PlaneSystemV3.rbxl (109.9 KB)
Raw Code:
local Speed = 50
local Weight = workspace.Gravity*ss:GetMass()
local Aimer = ss:WaitForChild("Aimer")
ss.AlignPosition.Enabled = true
local BodyForce = ss.VectorForce
BodyForce.Force = Vector3.new(0,Weight,0)
while true do
local Target = mouse.Hit
mouse.TargetFilter = workspace
Aimer.CFrame = Target
ss.CFrame = CFrame.new(ss.Position, Aimer.Position)
ss.AlignPosition.MaxVelocity = Speed
task.wait()
end
I looked in your test place, and it looks like the angular velocity of your spaceship is going crazy, probably because your AlignPosition and VectorForce/BodyForce is shifting the spaceship around in a place that isn’t its center of mass. When I reseted the angular velocity every frame, it wasn’t shifting in direction anymore.
It’s impossible to see the angular velocity change when you are CFraming the spaceship every frame, so that’s probably why you haven’t found the problem until now.
You can just tick the ApplyAtCenterOfMass property on both the AlignPosition and VectorForce, but I would still use something to regulate the angular velocity (such as an AngularVelocity instance).
@goldenstein64 Hey, thanks for the information. I ticked those and so far so good. I’m using it with the combination of @OrderDestroy fix.
@OrderDestroy Hey thanks for looking into it, it has made it better however the issue did occur still. But, as seen above, with the combination of @goldenstein64, it has been solid so far. It hasn’t occured.
Hopefully it stays this way and doesn’t occur again. But thank you both, I very much appreciate it.
I was stuck on this issue for literal weeks with no solution.