How can I prevent jittery movement when colliding with objects?

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!

I think it’s because there’s an X/Z fight with the position you give the vehicle when going forwards and the position the game tries to give for objects to stay outside of collision with other objects.

do you rememeber that sometimes in games there’s moments (bugs) where two pieces collide with each other and it does something like this? yeah it’s not a joke, many games have this issue where they have to use two different positions they give, one by the engine the other by the mechanisms. To fix this I would say use impulses to make the vehicle go forward when chosen to, and not change the position every frame, that’s bad. Then again I don’t know clearly how to fix it

If you feel impulse doesn’t work, try going to a separate world and make a car, then learn how that car goes forward and simulate that in your vehicle.

Im gonna say it, and Im gonna say it and don’t stop me from saying it. YOU SHOULD’VE READ MORE FROM THE FORUMS BEFORE POSTING. man, now I feel like I’m a roblox member

1 Like

I’ve looked on the devforum and haven’t found a solution that solves my issue, hence why I made a topic. I’ll look into impulses and see if that helps. Thanks!

Did you try to add a body gyro to it?? I know the problem your having is a collision, the collision of the 2 items, makes the item that can move go into the closest orientation, so the ship would lean forward a bit, and then get stuck in that specific orientation

Nvm I just saw you do have a bodygyro

The part of you checking the forum was a joke. A lot of people here tend to complain that people are asking for help and they do nothing to help them, instead they say that they should look at the forum more often or something.

1 Like

A neat idea I have is to change its direction to be perpendicular to the wall. I prepped the math here for you

1 Like

Hi.

Does anyone have any alternatives from BodyPositons I can use to combat this issue? Thanks!