Player "Hopping" When Running Down Slope

I’m making a Sonic game, and traveling down slopes is inconvenient at best.

When running down a slope the player skips off it, but i want the player to stick onto it. (like so)

I’ve looked through the forums and there’s like ONE other post with my issue, and it just doesn’t work for me.
I don’t know how to do anything pertaining to gravity or physics in general since I’ve only been scripting for 3-5 months. Any help would be nice, thanks!

Are you using a custom running script? Since you’re making a Sonic game, I can only assume you’ve made a custom sprinting script, or is this with Roblox’s basic running script?

If it is a custom sprinting script, if you could provide the code, I can try to look into it further, and it’d help out alot!

No, I dont know anything about custom controllers i fear; the only thing thats custom is the acceleration and still thats only increasing and decreasing the walkspeed

My fist thought for a solution is increasing gravity when the player isn’t jumping, and when they are decreasing gravity. Though that may mot be sufficient

If you have ever heard about mass slopes in physics, you may just know, why it’s doing this.

(in this case, mass is 488 kg (calculated around 1075.8 lbs). remember that Roblox has a different scaling feature, as called the RMU (Roblox Mass Unit))
We can take theta as 45 degrees recordedly.
Force of gravity=m * g * sin(θ), so Fg = 4889.81 * sin(45) = 488 * 9.81 * sqrt(2)/2 = roughly around 3385.11815 newtons
Reactive force = m
* g * cos(θ) = same as Force of gravity so its 3385 newtons.

That way we can find more stuff, such as the pull force, friction force, which are useful for this slope incline calculation.

It is not possible for the character to just turn like that instantly. To achieve this, you need to go through CustomPhysicalProperties, and increase Friction, FrictionWeight. Then you have MaxSlopeAngles, defines at what angle can the player go on. On the picture, you can tie it to the theta (the inclined plane’s angle). You could try doing things with AlignOrientation.

I mean that’s genuinely how physics works in this game using A level physics😭 (tip of the iceberg)

Could you give an example on how to use it in a script perchance :sob: I have no clue how i would apply this.

This may be a notable video to watch if you intend to add a slide mechanic that may resolve the issue you’re experiencing.

I dont plan on adding a slide but i’ll see if i can apply it in a general script, thanks twin :face_holding_back_tears:

No problem! I’ll keep researching alternatives in the meantime, and I’ll reply to you if I find anything!

This is a simpler solution and may require some editing of code, but it may be something worth looking into. You can possibly use the CollectionService to set which slopes you can have the player stick to and etc.

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")

local Player = Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()


local function AlignToSlope(wedge)
	local RootPart = Character:FindFirstChild("HumanoidRootPart")
	local Humanoid = Character:FindFirstChildWhichIsA("Humanoid")
	
	if not RootPart and not Humanoid then return end
	local Attachment = Instance.new("Attachment", RootPart)
	local AlignOri = Instance.new("AlignOrientation")
	AlignOri.Mode = Enum.OrientationAlignmentMode.OneAttachment
	
	AlignOri.Attachment0 = Attachment
	AlignOri.MaxTorque = 10^7
	AlignOri.Responsiveness = 50
	AlignOri.Parent = RootPart

	local Params = RaycastParams.new()
	Params.FilterDescendantsInstances = {Character}
	Params.FilterType = Enum.RaycastFilterType.Exclude

	RunService.RenderStepped:Connect(function()
		local RayOrigin = RootPart.Position
		local RayDirection = Vector3.new(0, -10, 0)
		local Result = workspace:Raycast(RayOrigin, RayDirection, Params)

		if Result then
			local SurfaceNormal = Result.Normal 
			local Look = RootPart.CFrame.LookVector
			local TargetCFrame = CFrame.fromMatrix(RootPart.Position, Look:Cross(SurfaceNormal), SurfaceNormal)

			AlignOri.CFrame = TargetCFrame
		else
			AlignOri.CFrame = CFrame.new(RootPart.Position)
		end
	end)
	
end

AlignToSlope(workspace.Part)
  • This runs on client btw, if you’re wondering.

This is just an example script I gave. It probably works or not, but it depends. You can improve it here, or take advices from @HiloTheFloof mentioned. Because this thing requires a lot of manipulation and physics knowledge. Basically what it does is it uses manipulation + raycasts to analyze how in realtime you get on any slope. It works exactly like the mass slope I mentioned, but to slow your speed down you need more friction and friction weight.

Okay so this didn’t fix the slope thing, neither did the smooth wall thing (cause i’m dumb), but it did allow for me to make a rudimentary velocity system! Thank you!!

glad to hear it helped in some way at least! Best of luck in your development!