Trying To Make Slide Mechanic Similar To RIVALS

In RIVALS, The Sliding Is Very Fluid And Responsive, Making for lots a movement tricks to be done using the map’s environment, and i’d like to implement a similar sliding mechanic into my FPS game, but I’m not sure how to achieve it, and was wondering if anyone could help, whether by giving some tips or even a explanation as to how Nosniy Games made their sliding system for RIVALS.

Below is my sliding script (Which uses Roblox’s new physics character controller):

local userInputService = game:GetService("UserInputService")

local replicatedStorage = game:GetService("ReplicatedStorage")

local character = script.Parent

local animation = Instance.new("Animation")

animation.AnimationId = "rbxassetid://137581948846855"

local animator = character:FindFirstChildWhichIsA("Humanoid"):FindFirstChildWhichIsA("Animator")

local animationTrack = animator:LoadAnimation(animation)

local debounce = false

userInputService.InputBegan:Connect(function(input)
	
	if input.KeyCode == replicatedStorage.Keybinds:GetAttribute("Crouch") then
		
		if debounce == false then
			
			local controllerManager = character:FindFirstChildWhichIsA("ControllerManager")
			
			local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")

			if controllerManager.ActiveController == controllerManager:FindFirstChildWhichIsA("GroundController") then
				
				debounce = true

				local attatchment = Instance.new("Attachment")

				attatchment.Name = "SlideAttatchment"

				attatchment.Parent = humanoidRootPart

				animationTrack:Play()

				local velocity = Instance.new("LinearVelocity")

				velocity.Attachment0 = attatchment

				velocity.ForceLimitsEnabled = false

				velocity.MaxAxesForce = Vector3.new(1, 0, 1) * 2500
				
				velocity.VectorVelocity = Vector3.zero
				
				if userInputService:IsKeyDown(Enum.KeyCode.W) then
					velocity.VectorVelocity = humanoidRootPart.CFrame.LookVector * 100
				elseif userInputService:IsKeyDown(Enum.KeyCode.A) then
					velocity.VectorVelocity = humanoidRootPart.CFrame.LookVector * -100
				end

				velocity.Parent = humanoidRootPart
				
				debounce = true
				
				shared.thread = coroutine.create(function()
					
					for count = 1, 8 do

						task.wait(0.125)

						velocity.VectorVelocity *= 0.75

					end
					
				end)
				
				coroutine.resume(shared.thread)
				
				shared.thread2 = coroutine.create(function()
					
					task.wait(.5)

					animationTrack:Stop()

					velocity:Destroy()

					attatchment:Destroy()
					
					task.wait(.5)

					debounce = false
					
				end)
				
				coroutine.resume(shared.thread2)
				
				shared.inputBegan = userInputService.InputBegan:Connect(function(input2)
					
					if input2.KeyCode == Enum.KeyCode.Space then

						coroutine.close(shared.thread)
						
						coroutine.close(shared.thread2)
						
						animationTrack:Stop()
						
						if velocity then
							velocity:Destroy()
						end
						
						if attatchment then
							attatchment:Destroy()
						end
						
						task.wait(.5)

						debounce = false
						
					end
					
				end)
				
				if debounce == false then
					shared.inputBegan:Disconnect()
				end
				
			end
			
			game:GetService("RunService").PreRender:Connect(function()
				
				if humanoidRootPart:FindFirstChild("SlideAttatchment") then
					
					if controllerManager.ActiveController == controllerManager:FindFirstChildWhichIsA("AirController") then

						task.wait(.075)

						local velocity = humanoidRootPart:FindFirstChild("Velocity")

						local attatchment = humanoidRootPart:FindFirstChild("SlideAttatchment")

						if velocity then
							velocity:Destroy()
						end

						if attatchment then
							attatchment:Destroy()
						end

						coroutine.close(shared.thread)

						coroutine.close(shared.thread2)

						debounce = false

						animationTrack:Stop()

						shared.inputBegan:Disconnect()

					end
					
				end
				
			end)
			
		end

	end
	
end)
3 Likes

For more context, my current sliding system (the script i provided above) tends to clip the player into slopes when sliding up them, and the player sliding forward off a slope instead of down it.

1 Like

You’ll want to detect the surface the player is touching and rotate the animation to be parallel.

Maybe calc your position delta in small increments to get the Vector parallel to the surface you are on and rotate the animation that way.

1 Like

The reason it would be doing this is because when you set the velocity, you are making it move forward no matter if an object is in front or not. So what you need to do is detect if there is a surface that it is on that isn’t horizontal and then rotate the player so that they are adjacent to that surface.

1 Like

@ModernWarSciFite @baadtiger

i’ve taken ur suggestions into consideration, tho after trying a few methods to do so, they haven’t seemed to work, maybe I’m not using right methods but I’m not sure

1 Like

Can you show us how you have tried to do it?

1 Like

Here’s a few methods i’ve tried:

(i’m not sure which ones, but some of the methods crashed my studio multiple times when i tried to run them, i probably wasn’t supposed to use them in a loop.)

1 Like

You need to make it so that it always happens, which I would assume would be in an infinite loop. When making an infinite loop, make sure that there is at least one wait statement of any length so that your game doesn’t crash.
I would recommend trying again but making sure it doesn’t crash, as these codes look as though they work.

1 Like

yea, im pretty sure these ones work fine, but some other ones made it crash, even when i put a task.wait() so im not sure, i’ll try seeing if i can get one of the methods working.

1 Like

Okay let me know what happens.

Alright, will do

(blahblablah)

1 Like


Alright, i managed to get it working! it took a few hours but i managed to get it to a stable degree (the floating character occurs on the client when sliding, tho it won’t be a issue as my game is gonna be first person.)

Good job. How’s sliding down slopes look?
I believe your intention was for the player to stick to the surface so that they do not slide off the top of a ramp but rather slide down with it.

Nice work! I hope all my advice helped!
Good luck with your game! (and make sure that when there was a solution, that you mark it as a solution so it doesn’t take up space).

for my use case i wanted the player to kinda be propelled into the air when jumping after sliding up a ramp, i’m gonna continue polishing it as the player does not slide down slopes unfortunately, so I’m gonna try using some raycasting and a VectorForce

yep, i have marked my previous reply as the solution, and thank you and @ModernWarSciFite for the help! as i was able to understand better what my problem was.

1 Like

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