Converted default Jeep suspension Tends to "Jump"

Hello there, i am trying to make a train system that follows a pre-made path, i have made the path system and it’s working perfectly fine, but the train starts to “Jump” once the train does around 2-3 laps around the track.
(Train at the starting point)


(Train jumping after 2.75 laps around the track)

i have been looking at some forum posts, and decided to clamp the values, but that only weakened the jumping, it didn’t stop it.

The code is running on .heartbeat currently, it ran on .stepped before, but heartbeat seems to give more reliable results.

the here is the separated suspension from the complete script, i have literally copy-pasted the jeep suspension in here, since the other suspensions i have tried making myself ended up working worse than this one.
EDIT: updated the script info

	function module.Connect(Bogie,DT)
	workspace.DestroyFolder:ClearAllChildren()
	---------suspension
	local Mass = math.clamp(Bogie.Parent.AssemblyMass+Bogie:GetMass(),0,1)*workspace.Gravity
	--print(Mass)
	local force = Mass*3
	local damping = force / 10
	local height = 0.3
	local thruster = Bogie
	local bodyThrust = Bogie.BodyThrust
	local Result = workspace:Raycast(thruster.Position, thruster.CFrame:vectorToWorldSpace(Vector3.new(0, -1, 0)) * height)
	local hit, position = Raycast.new(thruster.Position, thruster.CFrame:vectorToWorldSpace(Vector3.new(0, -1, 0)) * height)
	local thrusterHeight = (position - thruster.Position).magnitude
	if hit and hit.CanCollide then
		--If we're on the ground, apply some forces to push the wheel up
		bodyThrust.force = Vector3.new(0, ((height - thrusterHeight)^2) * (force / height^2), 0)
		local thrusterDamping = thruster.CFrame:toObjectSpace(CFrame.new(thruster.Velocity + thruster.Position)).p * damping
		bodyThrust.force = bodyThrust.force - Vector3.new(0, thrusterDamping.Y, 0)
	else
		bodyThrust.force = Vector3.new(0, 0, 0)
	end

i have put the damping to 10 because it seems to be the most stable after some tuning

2 Likes

after some more investigating, i found that the script performance is above 25% to 90%?
image
image
Might this have something to do with it?
EDIT:
After disabling my raycast params, it is below 3% again.
image
And it is still having the jumping issues.

1 Like

Im guessing this is on a server script? Does this happen if somebody goes on the train or near it? Mainly because I had an issue with scripted suspension with im guessing, network physics causing wierd issues. If you dont have anyluck, and I know this prob goes against the goal, potentially using Spring constraints. They work quite well when you set them up correctly. Good luck!

2 Likes

Does it run on server Script?

yes, i’ll be seeing if i can convert it to localscript possibly.

using spring constraints

I simply can’t use spring constraints on this scale, the train’s height is below 0.25 studs off the ground, spring constraints simply wouldn’t work with this small of a distance in my experience

1 Like

Thanks, i converted it to a localscript, and it works flawlessly!

2 Likes