Help with sliding system

  1. What do you want to achieve? Keep it simple and clear!
    I want to create a sliding system for my movement system.
  2. What is the issue? Include screenshots / videos if possible!
    When I slide in third person, the player spins around a bit, and even in first person it spins just a little before realigning
  3. What solutions have you tried so far? Did you look for solutions on the Creator Hub?
    I’ve tried looking on devforum but nobody has my problem

My velocity function:

local function Velocity(VectorVelocity, Part)
	local LinearVelocity = Instance.new("LinearVelocity")
	local Atch = Instance.new("Attachment")
	Atch.Parent = Part
	LinearVelocity.RelativeTo = Enum.ActuatorRelativeTo.World
	LinearVelocity.VectorVelocity = VectorVelocity
	LinearVelocity.MaxForce = math.huge
	LinearVelocity.Attachment0 = Atch
	LinearVelocity.Parent = Atch
	
	return LinearVelocity, Atch
end

and my slide function:

local function Slide()
	if not IsRunning then return end
	IsSliding = true
	if Hum.FloorMaterial == Enum.Material.Air then
		repeat task.wait() until Hum.FloorMaterial ~= Enum.Material.Air or not IsSliding
	end
	local CurrentSpeed = Info.Slide.SlideSpeed
	LinearVelocity, Atch = Velocity(HRP.CFrame.LookVector*CurrentSpeed, HRP)
	PlayAnim("Slide", 0.3)
	repeat
		CurrentSpeed *= 0.95
		LinearVelocity.VectorVelocity = HRP.CFrame.LookVector*CurrentSpeed
		task.wait(0.08)
	until not IsSliding
end

thanks :slight_smile:

2 Likes

Show us a video of the problem

characters

1 Like

It may be, that if the character is auto-rotating to match the velocity, then it rotates the character a little to the right, and this line

LinearVelocity.VectorVelocity = HRP.CFrame.LookVector*CurrentSpeed

Adapts to the new rotation, which is a little to the right and then the loop just continues. Try changing that line to this fpr example

Avoid getting the Unit of a zero vector
if LinearVelocity.VectorVelocity ~= Vector3.zero then
    LinearVelocity.VectorVelocity =     LinearVelocity.VectorVelocity.Unit*CurrentSpeed
end

Tho I’m not 100% sure if this creates the behaviour you are trying to achieve

Figured it out. I simply had to change the MaxForce value

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.