Вот мой код для системы подвески машин в roblox: [code] Машиа постоянно прыгает.…
- User
Вот мой код для системы подвески машин в roblox:
ENABLED = true local WheelHitbox = 1 -- Ширина колеса local SuspensionHeight = 2 -- Уменьшил высоту подвески local Player = game.Players.LocalPlayer local SeatPart = Player.Character.Humanoid.SeatPart local Chassis = SeatPart.Parent local Wheels = Chassis:WaitForChild("wheels") local WheelsSpherecast = Chassis:WaitForChild("wheels_spherecast") local FUNCTIONS = {} function FUNCTIONS:CastWheel(wheel, SpherecastWheel) local raycastParams = RaycastParams.new() raycastParams.FilterType = Enum.RaycastFilterType.Exclude raycastParams.FilterDescendantsInstances = {wheel} local raycastResult = workspace:Shapecast(SpherecastWheel, Vector3.new(0, -SuspensionHeight, 0), raycastParams) if raycastResult then local pos = raycastResult.Position local dist = (SpherecastWheel.Position - pos).Magnitude local norm_dist = dist-SpherecastWheel.Size.Y/2 local offset = SuspensionHeight-norm_dist -- Отклонение колеса от предельного упора вниз local NORMAL = raycastResult.Normal return norm_dist, offset, NORMAL else return SuspensionHeight, 0, nil end end function FUNCTIONS:ApplyWheelForce(SpherecastWheel, offset, NORMAL) if SpherecastWheel and offset and NORMAL then local multiple = offset/SuspensionHeight local SpherecastWheelAssemblyMass = SpherecastWheel.AssemblyMass local impulse = SpherecastWheelAssemblyMass*multiple local passive_add = SpherecastWheelAssemblyMass*0.9 impulse = impulse*2+passive_add --impulse * (1 - damping) -- Умножил импульс на коэффициент print(impulse) SpherecastWheel:ApplyImpulseAtPosition(NORMAL*impulse, SpherecastWheel.Position) --SpherecastWheel.CFrame.UpVector end end while ENABLED do for i, wheel in pairs(Wheels:GetChildren()) do local SpherecastWheel = WheelsSpherecast:GetChildren()[i] local norm_dist, offset, NORMAL = FUNCTIONS:CastWheel(wheel, SpherecastWheel) if norm_dist then print("wheel: "..wheel.Name.."; norm_dist: "..norm_dist.."; offset: "..offset) wheel.Position = SpherecastWheel.Position - Vector3.new(0, norm_dist, 0) FUNCTIONS:ApplyWheelForce(SpherecastWheel, offset, NORMAL) end end wait() endМашиа постоянно прыгает. Используй реальные физические формулы для имправления этой проблемы. Используй только существующие функции
- Assistant