Hi, I was wondering if I could have some help with implementing pacejka longitudinal friction, I have successfully implemented pacejka lateral friction and it works how I need it to now its just longitudinal friction I need for doing burnouts in vehicles and I don't know how to implement it with the formulas I have found on the internet.
This is my pacejka function
pacejka = function(slip, surface)
if surface then
local x = slip
local b = surface.Stiffness -- Stiffness
local c = surface.Shape -- Shape
local d = surface.Peak -- Peak
local e = surface.Curve -- Curve
return d * math.sin(c * math.atan(b * x - e * (b * x - math.atan(b * x))));
end
return 0
end
And here's a snippet of my implementation of lateral friction
local WheelVelocity = self.GetPointVelocity(self.Engine, attachPosition + attachDirection)
local RelativeWheelVel = force.WorldCFrame:VectorToObjectSpace(WheelVelocity)
self.angularVelocity[force.Name] = (RelativeWheelVel / (math.pi*2) * self.WheelRadius)
local lateralVelocity = RelativeWheelVel.X
local longitudinalVelocity = RelativeWheelVel.Z
local slipAngle = math.deg(math.atan2(lateralVelocity, math.abs(longitudinalVelocity * self.stopWheels)))
--local slipRatio = ((Weld.Part1.RotVelocity.Z * self.WheelRadius) - longitudinalVelocity) / math.max(math.abs(longitudinalVelocity), 0.00001)
local pacejkaLatValue = self.pacejka(slipAngle, self.wheelSurface[force.Name]);
--local pacejkaLongValue = self.pacejka(slipRatio * 100, self.wheelSurface[force.Name]);
local totalTireLoad = Length * (Mass * Grip)
local tireLoad = math.clamp((1-(-self.springLength[force.Name] / 6.9*(2.5))) * (Mass * Grip), 0, totalTireLoad)
--local longForce = (tireLoad* (pacejkaLongValue / 2)) / 4
local lateralForce = (tireLoad * pacejkaLatValue) / 4
drivForce.Force = Vector3.new(-lateralForce, 0, longtitudinalForce.Z)
Yes I have clamped my lateral friction so it doesn't have any weird behavior but just for the sake of keeping it short i have slightly edited my code to not include it
also, the longtitudinalForce
shown in the code snippet is just my power calculation
the friction graph is displaying the friction only for the front left wheel.
Any help implementing longitudinal friction is appreciated!