Hello, just having a small issue. Currently, whenever I try and slide the LinearVelocity will automatically redirect the velocity to the players HumanoidRootPart, which is fine however I want this process to a longer time, I want it to take longer to switch direction between what their current velocity unit is and which direction they are looking in.
self.slidingConnection = runService.RenderStepped:Connect(function()
--// Reset velocity if player encounters a wall
local forwardRaycast = game.Workspace:Raycast(
humanoidRootPart.Position,
humanoidRootPart.CFrame.LookVector * 2.5,
newRaycastParams
)
if forwardRaycast then
self.slidingVelocity.VectorVelocity = Vector3.new(0, 0, 0)
end
--// Add decay
self.slidingVelocity.VectorVelocity *= .955
self.slidingVelocity.VectorVelocity = humanoidRootPart.CFrame.LookVector * (self.slidingVelocity.VectorVelocity.Magnitude)
--// 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) then
if (self.settings.activated_states['slidingMovement']) then
self:dequeueMovement('cMovement')
end
return
end
end)
Never mind figured it out, here’s the code if anyone’s interested:
self.slidingConnection = runService.RenderStepped:Connect(function()
--// Reset velocity if player encounters a wall
local forwardRaycast = game.Workspace:Raycast(
humanoidRootPart.Position,
humanoidRootPart.CFrame.LookVector * 2.5,
newRaycastParams
)
if forwardRaycast then
self.slidingVelocity.VectorVelocity = Vector3.new(0, 0, 0)
end
--// Add decay
self.slidingVelocity.VectorVelocity *= .955
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) then
if (self.settings.activated_states['slidingMovement']) then
self:dequeueMovement('cMovement')
end
return
end
end)