Intro
Hello there! In physics, adding friction is multiplying the velocity by the coefficient, by doing so it decreases the velocity. However, when attempting to remove friction in certain directions, I ran across some strange behavior.
My attempt
I used a body velocity, and removed the body velocity's velocity by the right vector, then the left vector by lerping using friction
local BodyVelocity = workspace.Vehicle.BodyVelocity
function Physics:ApplyFriction(Friction)
--//Left and Right
local RightVector = (Vehicle.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(90),0)).LookVector
local LeftVector = (Vehicle.PrimaryPart.CFrame * CFrame.Angles(0,math.rad(-90),0)).LookVector
local RightFriction = BodyVelocity.Velocity * RightVector
local LeftFriction = BodyVelocity.Velocity * LeftVector
--//Right
BodyVelocity.Velocity = BodyVelocity.Velocity:Lerp(BodyVelocity.Velocity - RightFriction, Friction)
--//Left
BodyVelocity.Velocity = BodyVelocity.Velocity:Lerp(BodyVelocity.Velocity - LeftFriction, Friction)
end
My problem
Firstly, this is very inefficient, secondly, It doesen't work that well, any suggestions to improve it?
