Hello! I have an issue when using BodyMovers where when I crash into a wall/object, my spaceship will glitch out and “stick” to the wall. How can I fix this?
Here is examples of the issue:
https://gyazo.com/ce18d498eac0fdd7e6f1cf1ec4cf1399
https://gyazo.com/a96d2507581e4744d07b7ea696e2dbc5
Here is my code:
--ServerScript to load the ship
local bav = Instance.new("BodyAngularVelocity")
local bg = Instance.new("BodyGyro")
local bp = Instance.new("BodyPosition")
bav.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
bav.AngularVelocity = Vector3.new(0,0,0)
bav.Parent = ship.PrimaryPart
bg.MaxTorque = Vector3.new(math.huge, 0, math.huge)
bg.Parent = ship.PrimaryPart
bp.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
bp.Parent = ship.PrimaryPart
bp.Position = Vector3.new(775.364, 0, 2558.981)
--LocalScript to control player movement
if backwardsToggel or forwardToggel then
local speedShip = root.CFrame.LookVector * speed
if backwardsToggel then
root.BodyPosition.Position = Vector3.new((root.BodyPosition.Position - speedShip).x, 0, (root.BodyPosition.Position - speedShip).z)
end
if forwardToggel then
root.BodyPosition.Position = Vector3.new((root.BodyPosition.Position + speedShip).x, 0, (root.BodyPosition.Position + speedShip).z)
end
end
if leftToggel or rightToggel then
if leftToggel then
tweenService:Create(root.BodyAngularVelocity, TweenInfo.new(.6,Enum.EasingStyle.Quint, Enum.EasingDirection.Out),{AngularVelocity = Vector3.new(0,1,0)}):Play()
end
if rightToggel then
tweenService:Create(root.BodyAngularVelocity, TweenInfo.new(.6,Enum.EasingStyle.Quint, Enum.EasingDirection.Out),{AngularVelocity = Vector3.new(0,-1,0)}):Play()
end
end
if not leftToggel and not rightToggel then
tweenService:Create(root.BodyAngularVelocity, TweenInfo.new(.6,Enum.EasingStyle.Quint, Enum.EasingDirection.Out),{AngularVelocity = Vector3.new(0,0,0)}):Play()
end
I tried using BodyGyros to prevent rotation on axis’, but it did not work. Any help is appreciated, thank you!