So I have a function that controls the way the character glides.
It works mostly how I envisioned except there is one issue: The Y velocity can get reduced to 0 and the player will stop moving completely.
Here is the code:
local function startGliding()
isGliding = true
Humanoid.HipHeight = 0.001
print(animationStartGliding,animationTrackStartGliding)
animationTrackStartGliding:Play()
Humanoid:SetStateEnabled(Enum.HumanoidStateType.FallingDown,false)
Humanoid:SetStateEnabled(Enum.HumanoidStateType.Ragdoll,false)
RunService.Stepped:Connect(function(time, delta)
if(isGliding) then
local cameraVector:Vector3 = camera.CFrame.LookVector
local angle:Vector3 = cameraVector:Dot(Vector3.new(0,1,0))
angle = workspace.CurrentCamera.CFrame.LookVector:Dot(Vector3.new(0,1,0))
HRP.CFrame = HRP.CFrame:Lerp(CFrame.new(HRP.Position) * (camera.CFrame.Rotation), 0.02)
HRP.AssemblyLinearVelocity = HRP.CFrame.LookVector * HRP.AssemblyLinearVelocity.magnitude
animationTrackGliding:AdjustSpeed(HRP.AssemblyLinearVelocity.magnitude * 0.005)
end
end)
end
I’ve tried a lot of things and I just ended up doing something overcomplicated every time.
Let me know if you have any ideas what I’m missing. Here is the video: