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
Works with keyboard controls only, but feel free to add other controls!
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)
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
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
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.
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.
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