Right now I’m making a terrain climbing system for my game and it works pretty smoothly except that the player rotates to every small budge it sees in the terrain, even if it’s the tiniest of angle difference.
Here’s a visualization of the bug;
As you can see, it looks pretty awkward, hence I’d like to change it.
So I would like the player to only rotate when there’s a difference of at least 5 degrees, however, I have no idea how to calculate the difference of angles, even after looking at other posts.
-- Current code:
while true do wait(0.05)
local hit,pos,surface = SurfaceCheck() -- I'm using raycast.
humanoidRootPart.CFrame = CFrame.new(pos,pos + surface)
humanoidRootPart.CFrame = humanoidRootPart.CFrame * CFrame.new(0,0,-2) * CFrame.Angles(math.rad(0),math.rad(180),math.rad(0))
end
Thank you for reading