I implemented a slide mechanic, but whenever a player presses slide as soon as they jump and they land, the character seems to shake, any way around this? (https://gyazo.com/ab24b84e995337d1c04f53866d8d85d5)
function slidingMovement:activate()
--// Make sure that hte movement doesnt exist yet
if (self.slidingConnection ~= nil) then
return
end
--// Check cooldown
if (self.cooldown and tick() - self.cooldown < self.localSettings.cooldown) then
return 'cooldown'
end
--// Configuration
self.redirectingSlopeRotation = false
--// Apply settings
self.settings.activated_states['slidingMovement'] = true
self.cooldown = tick()
--// Change walkspeed
humanoid.WalkSpeed = self.localSettings.walkSpeed
humanoid.JumpPower = self.localSettings.jumpPower
head.CanCollide = false
torso.CanCollide = false
--// Calculate presettings for sliding
local initialVelocity = (humanoidRootPart.CFrame.LookVector * 110)
--// New body velocity
self.slidingVelocity = Instance.new('LinearVelocity')
self.slidingVelocity.Attachment0 = humanoidRootPart.RootAttachment
self.slidingVelocity.VectorVelocity = initialVelocity
self.slidingVelocity.ForceLimitMode = Enum.ForceLimitMode.PerAxis
self.slidingVelocity.MaxAxesForce = Vector3.new(math.huge, -10, math.huge)
self.slidingVelocity.Parent = humanoidRootPart
self.slidingConnection = runService.RenderStepped:Connect(function()
--// Check if player is currently on a slope
local slopeRaycast = game.Workspace:Raycast(
humanoidRootPart.Position,
Vector3.new(0, -4, 0),
newRaycastParams
)
local topPartRaycast = game.Workspace:Raycast(
humanoidRootPart.Position,
Vector3.new(0, 3, 0),
newRaycastParams
)
local forwardRaycast = game.Workspace:Raycast(
character['Left Leg'].Position,
humanoidRootPart.CFrame.LookVector * 2.5,
newRaycastParams
)
--// If player is currently sliding under a part then make sure they can't cancel slide
if (topPartRaycast) then
self.settings.runtime_config.canCancelCMovement = false
else
self.settings.runtime_config.canCancelCMovement = true
end
if forwardRaycast then
self.slidingVelocity.VectorVelocity = Vector3.new(1, 0, 1)
end
self.slidingVelocity.VectorVelocity *= self.settings.runtime_config.canCancelCMovement and .955 or 1
local distance = (
(humanoidRootPart.CFrame.LookVector - self.slidingVelocity.VectorVelocity.Unit) -- Get point between where velocity is facing and where humanoidrootpart is facing
) / 85 -- Divide it by how much you want
local newDistance = (self.slidingVelocity.VectorVelocity.Unit + distance) * self.slidingVelocity.VectorVelocity.Magnitude -- Add this distance to current velocity unit and set magnitude back to previous
self.slidingVelocity.VectorVelocity = newDistance
--// Check if we can end the slide
local minimumMagnitude = table.find(self.settings.queuedMovement, 'sprintMovement') and 16 or 8
if (self.slidingVelocity.VectorVelocity.Magnitude <= minimumMagnitude and self.settings.runtime_config.canCancelCMovement) then
if (self.settings.activated_states['slidingMovement']) then
self:dequeueMovement('cMovement')
end
return
end
--[[if slopeRaycast and math.acos(slopeRaycast.Normal.Y) > 0 then
else
end--]]
end)
--// Play the animations
self:playAnimation('sliding', 'action', .125)
self:changeAnimationPriority('sliding', 'action', Enum.AnimationPriority.Movement)
task.wait(.4)
self:adjustAnimationSpeed('sliding', 'action', 0)
end