I'm writing some code that will simulate the avatar sliding down the truss whenever the player holds down left control. In reality, it's just upping the humanoid.WalkSpeed, playing an animation, and forcing the avatar to move backwards relative to the HumanoidRootPart look vector. But when you're climbing, it makes the player move up when you are holding S and looking behind the avatar. Here's my script to try and compensate for that:
if (inputObject.KeyCode == Enum.KeyCode.LeftControl) then
if isClimbing then
Slide = true
slideAnim:Play()
humanoid.WalkSpeed = slideSpeed
SlideStepped = RUN_SERVICE.RenderStepped:Connect(function()
angle = math.acos(
math.clamp(
currentCamera.CFrame.LookVector:Dot(RootPart.CFrame.LookVector),
-1,1)
)
if angle > math.pi/2 then
backwards = true
else
backwards = false
end
if not backwards then
humanoid:Move(Vector3.new(0,0,1), true)
else
humanoid:Move(Vector3.new(0,0,-1), true)
end
end)
end
end
It works for the most part, but there's this sweet spot in the middle that sends the player flying up. How do I fix this?
