Momentum Controls

Momentum Controls Demo

A character control script that allows you to adjust the momentum (using the rate constant found in line 6), without using physics constraints. Something I made for fun, but made sure to test it as always :grin:

Works with keyboard controls only, but feel free to add other controls!

You can find it here :slight_smile:


Momentum Controls 2 has been released with gamepad and touch support!
22 Likes

Screenshots and videos?, we need it to see before taking the source.

1 Like

The “Momentum Controls Demo” link at the top of my post is a video recording I took of my character moving using the script, although I must admit since viewers can’t see when I stop pressing keys, it’s a bit difficult to tell when it’s taking effect (The effect is most prominent imo when I move from left to right in the clip)

1 Like

The same thing can be achieved by setting the friction of all your character parts to a number between 0 and 1.

2 Likes

The difference is that this script makes it easier to adjust the momentum’s duration due to the rate’s unit being seconds. You’d need to use trial-and-error to find the right friction value to match your goal, and also have to worry about friction weights

4 Likes

I used to use friction 0 - 1 but this looks way better.

Using friction made my movement script slippery and annoying to do parkour on. Thanks for this resource!

2 Likes

Very nice. But.

After trying to implement it I found a few issues.

  1. It doesn’t work unless specifically named “ControlScript” (I renamed it)
  2. It doesn’t work unless specifically a child of (Starter)PlayerScripts (I placed it into a folder)
  3. If the above two issues are solved, it prevents PlayerModule from being added to PlayerScripts when the player loads (I need PlayerModule to load)

Why is that?

1 Like

The answer for the first and second questions can be found by reading the third paragraph of this article

For the third question: the reason why the PlayerModule isn’t created is a consequence of replacing the default control script, which you must do in order for Momentum Controls to work otherwise it would cause conflicts and unwanted behavior

1 Like

Alright thank you.
This works very close to how I want my movement to be and it’s very easy to use and doesn’t really interfere with other scripts I use.

The only thing I’d ask for is an explanation of how it works so that I can change it more, since I absolutely have no idea how it works.

2 Likes

Hi, Can you elaborate on ‘otherwise it would cause conflicts and unwanted behavior’ and what they are?

It like your controller, thanks for sharing it!

2 Likes

I literally use chickynoids because they give you more control over their physics, but this is pretty nice for people who still want to use humanoids, good resource it makes movement more realistic and less stiff, I wonder how it looks when a player jumps and then lands.

2 Likes

It uses the delta time provided by BindToRenderStep in order to increase the direction values, while clamping the result so the value doesn’t go past 0 or 1 to keep the rate’s math simple to use. The rate (found at line 6) as I stated in the main post uses seconds as a unit, so for example

  • If the rate is 1, the character will take approximately 1 second to reach its walk speed or slow down back to 0
  • If the rate is 4, the character will instead take approximately 0.25 seconds to do the above and the delay between movements will be unnoticeable
  • If instead the rate is a fraction (for example, 1/4), the character will take ≈ 4 seconds, and the delay between movements will be large

Note if for example the character stops moving forward before reaching its maximum walk speed (let’s say max is 16 and it stopped when it was at 8) and the rate is 1, the character will instead take 0.5 seconds to reach 0 walk speed which is realistic as an object travelling at a slower speed will (assuming all conditions are equal) take less time to decelerate than a fast moving object

The reason why I’m using approximate (≈) a lot is due to the nature of delta time, since the rate is multiplied by the delta and the delta being a value that varies according to the load being experienced by the device you are using to play

2 Likes

The best example I can give is: Imagine two people trying to drive a car at the same time, it would be chaos!

1 Like

Unfortunately Momentum Controls doesn’t affect how characters jump, but thank you for your support!

2 Likes

you should add this it would make it so much better.

1 Like