Hello, today I tried to make a suspension system with the tutorial. I’m a very beginner. Idk whats the problem ![]()
GUYS I TRIEDD EVERY PLATFORM PLS HELP
Footage:
(At the 2:02 part) Tutorial
local car = workspace.Car
local WheelPositions = {
FL = Vector3.new(-2.5, 0, -6.25),
RL = Vector3.new(-3.5,0,6),
FR = Vector3.new(-2.5, 0, 6.25),
RR = Vector3.new(2.5, 0, 6.25),
}
local SuspensionLengtMemory = {}
for i,v in pairs(WheelPositions)do SuspensionLengtMemory[i] = 0.5 end
local suspensionMaxLength = 1.3
local wheelRadius = 0.5
local Stiffness = 70
local Damper = 5
car:SetNetworkOwner(nil)
while true do
local delta = game:GetService(“RunService”).Heartbeat:Wait()
for wheelName, originalPosition in pairs(WheelPositions)do
local carCFrame = car.CFrame
local rayOrigin = carCFrame:ToWorldSpace(CFrame.new(originalPosition)).Position
local rayDirection = -car.CFrame.UpVector * (suspensionMaxLength + wheelRadius)
local raycastParams = RaycastParams.new()
local raycast = workspace:Raycast(rayOrigin,rayDirection,raycastParams)
if raycast then
local RaycastDistance = (rayOrigin - raycast.Position).Magnitude
local SpringLength = math.clamp(RaycastDistance - wheelRadius, 0, suspensionMaxLength)
local StiffnessForce = Stiffness * (suspensionMaxLength - SpringLength)
local DamperForce = Damper * ((SpringLength - SuspensionLengtMemory[wheelName] - SpringLength) / delta)
local SuspensionForceVec3 = carCFrame.UpVector * (StiffnessForce + DamperForce)
SuspensionLengtMemory[wheelName] = SpringLength
car:ApplyImpulseAtPosition(SuspensionForceVec3, raycast.Position)
end
end
end