Ok so as the title has mentioned how does the jeep’s suspension work. I’ve managed to figure out some part of it and relatively understand a little bit of how does it work but the algorithm confused me:
local force = 0
local damping = 0
local mass = 0
for i, v in pairs(car:GetChildren()) do
if v:IsA("BasePart") then
mass = mass + (v:GetMass() * 196.2)
end
end
I know this part is to calculate what my school call P and P = m*g with g as the acceleration of gravity and i only understand this part of the algorithm
However, the way that they calculate force and damping makes me confused:
force = mass * stats.Suspension.Value
damping = force / stats.Bounce.Value
What does it mean? Why do they do it this way because perhaps i haven’t learned it in school yet but it makes me really confused?
I think this part in the updatethruster function is used to make the suspension but it is also quite hard to understand as the one above:
local bodyThrust = thruster:FindFirstChild("BodyThrust")
if not bodyThrust then
bodyThrust = Instance.new("BodyThrust", thruster)
end
--Do some raycasting to get the height of the wheel
local hit, position = Raycast.new(thruster.Position, thruster.CFrame:vectorToWorldSpace(Vector3.new(0, -1, 0)) * stats.Height.Value)
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, ((stats.Height.Value - thrusterHeight)^2) * (force / stats.Height.Value^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
To be honest, i really need someone to make the algorithm clear to me because i’ve been struggled with this for 2 weeks so pls help