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