When I try to slide this happens:
What I want to happen:
My code:
-- functions
function gNF()
local ray = workspace:Raycast(hrp.Position,hrp.CFrame.UpVector*-8,plrBl())
if ray then
local currentRightVector = hrp.CFrame.RightVector
local upVector = ray.Normal
local newFacialVector = currentRightVector:Cross(upVector)
return newFacialVector,upVector,currentRightVector,ray
else
return
end
end
function sSG()
local nFV,up,cRV = gNF()
if nFV and up and cRV then
ao.CFrame = CFrame.lookAt(Vector3.zero,hrp.AssemblyLinearVelocity)
--ao.CFrame = CFrame.fromMatrix(hrp.Position, cRV, up, nFV)
end
end
function svwdxay(Old,NewY)
return Vector3.new(Old.X,NewY,Old.Z)
end
-- sliding
local nFV,up,cRV,ray = gNF()
local rh = var.d and 1
local lh = var.a and -1
if (slideDir == 0) or (slideDir == 1 and not rh) or (slideDir == -1 and not lh) then
slideDir = rh or lh or 0
end
if ray then
local floorNormal = ray.Normal
local linearVelo = hrp.AssemblyLinearVelocity
--var.velo += ((var.velo * ((math.abs(floorNormal.Y-1)-floorNormal.Y==1 and .01 or 0)*15)))*dt
linearVelo = linearVelo-floorNormal*linearVelo
local rotEase = math.max((1-floorNormal:Dot(Vector3.yAxis)),.1)
hrp.AssemblyLinearVelocity = CFrame.fromAxisAngle(floorNormal, rotEase*slideDir*dt)*linearVelo
sSG()
--bv.Velocity = CFrame.fromAxisAngle(floorNormal, rotEase*slideDir*dt)*linearVelo
var.curSlide -= 10*dt
--bv.MaxForce = Vector3.new(1,0,1)*100000
if var.curSlide <= 5 or var.space then
slideStop()
end
end
I will come back to this tomorrow, it’s 03:11 atm