Sliding System With Gravity?

How would I make a sliding system that takes into account gravity? When I apply velocity using a linear velocity, body velocity, or setting the HRP velocity, it ignores gravity when going down and the character floats instead of falling (eg. sliding down a cliff edge will just make them float, and then they drop after the slide ends)

What if you shoot a raycast downward 1/2 stud below the player’s feet while sliding. If there is something underneath them continue the slide, but if there is nothing there start adding a force that’s equal to gravity.
Instead of floating or dropping immediately you’d probably be able to fine tune more of a normal arc.

Is it not possible to not ignore gravity with velocities?

Dunno, I’ve never really explored them too much.


When I try to balance out the gravity it looks like this:

If you’re working with a BodyVelocity then set the Y of the MaxForce to 0. Otherwise I don’t know

1 Like

You’re imparting an inertia on the Y-axis through those body-movers. Simply by having no Y-axis value set, with maximum influence over the Y-axis by default, you zero out any Y-axis influence for the duration of the body-mover’s lifetime, which includes influences from gravity. Set 0 on the Y axis of your max force to solve that issue

2 Likes

The problem is the 2 movers use forces to control the Y axis too (so if you have it set to 0, they will try to keep the Y velocity at 0), and I’m assuming that you’re setting the HRP velocity to the slide direction which also sets the Y velocity at 0. The goal is to keep the Y velocity affected by gravity, so you should ignore it while only influencing the X/Z velocity components.

For LinearVelocity:

  • Set ForceLimitMode to PerAxis
  • Set MaxAxesForce to the force you want to use, but keep Y at 0
    • ex: Vector3.new(5000, 0, 5000)

For BodyVelocity:

  • Set MaxForce to the force you want to use, but keep Y at 0 (see above)

For manually setting the HRP velocity:

  • Copy whatever the last frame’s Y velocity was (in effect, you’re not changing it)
    • ex:
RunService.PreSimulation:Connect(function(deltaTimeSim: number)
   -- get current velocity 
   local currentVelocity = HRP.AssemblyLinearVelocity
   -- calculate the slide velocity (however you do that)
   local slideVelocity = slideDirection * slideSpeed 
   -- calculate the HRP's actual new velocity 
   local newVelocity = Vector3.new(
      slideVelocity.X,
      currentVelocity.Y, -- you are doing nothing to the Y axis
      slideVelocity.Z
   )
   -- apply to HRP
   HRP.AssemblyLinearVelocity = newVelocity
end)
1 Like

What if you simply

HRP.AssemblyLinearVelocity *= 10

And then reduce the friction?