Page 1 of 1

inertia.lua - Keep your speed on moving npcs!

Posted: Sat Mar 09, 2024 9:50 am
by Master of Disaster
You may know the moment when you are trying to platform on a moving platform (looking at you, red YI platform) and it's hard to stay on the platform and feels wrong as well.
The lack of inertia in SMBX bothered me at least, so here's a little library that fixes that!

inertia.lua v1.1

With this library you keep your momentum on moving npcs, making it a lot easier to stay on a moving platform.
Additionally, your jump height is effected by the vertical speed of the platform! You can get quite a lot of distance with that.

v1.1 fixes two issues:
- Fixed an oversight where jumping to the left capped your speed at your runspeed
- NPC's layer movement now also affects you

You can customize how it works with these:

Code: Select all

local inertia = require("inertia") -- loads the library

inertia.keepSpeed = 1 -- how much speed you keep when leaving the platform
inertia.maxJumpSpeed = -16 -- the highest vertical speed you can get when jumping off a moving platform
inertia.minJumpSpeed = -3   -- the lowest vertical speed you get when jumping off a moving platform.
inertia.maxSpeedX = 6          -- highest horizontal speed. If > 6, you can get faster than your normal running speed, it reverts back to normal when landing
here's a little bit of footage:
Spoiler: show
inertia off:
Image

inertia on:
Image

credit if used yadda yadda you know the drill

Here's the download:
https://www.dropbox.com/scl/fo/4in7q8fj ... zn5pp&dl=0

Re: inertia.lua - Keep your speed on moving npcs!

Posted: Sat Mar 09, 2024 12:41 pm
by AirShip
Inertia, my beloved--
Great work, useful as always!

Re: inertia.lua - Keep your speed on moving npcs!

Posted: Sat Mar 09, 2024 8:22 pm
by King Mario
When I try it, an error appears saying that "jumpspeed" does not exist. Know how to fix this?

Re: inertia.lua - Keep your speed on moving npcs!

Posted: Mon Mar 11, 2024 8:55 am
by Master of Disaster
King Mario wrote:
Sat Mar 09, 2024 8:22 pm
When I try it, an error appears saying that "jumpspeed" does not exist. Know how to fix this?
jumpspeed doesn't exist? That's an error message you get when using beta 4, since Defines.jumpspeed was recently added in beta 5.
If you are still using beta 4, I'd advice you to update smbx, as there is no reason to not do

Re: inertia.lua - Keep your speed on moving npcs!

Posted: Tue Mar 12, 2024 3:50 pm
by King Mario
I switched to Beta 5 and it works! Thank you for the suggestion.

Re: inertia.lua - Keep your speed on moving npcs!

Posted: Sun Mar 17, 2024 8:49 pm
by Blake Izayoi
This will absolutely come in handy in a lot of scenarios. Marvelous work!

Re: inertia.lua - Keep your speed on moving npcs!

Posted: Tue Mar 18, 2025 12:43 am
by cold soup
Spoiler: show
Image
found an oversight when your maximum X-speed is set to a value above your regular max run speed. while jumping to the right makes your momentum carry just fine, jumping to the left still caps your speed

Re: inertia.lua - Keep your speed on moving npcs!

Posted: Wed Mar 19, 2025 7:31 am
by Master of Disaster
Oh that's odd, definitely gonna look into the code to see what's the issue

Added in 2 minutes 52 seconds:
Alright, updated the library to fix the speed cap oversight, and additionally properly handle layer movement on npcs.