SmallJoker / boost_cart

The original version of minetest_game's carts (since 2018).
15 stars 14 forks source link

Cart jerks when moving up and down hills at low speeds. #27

Open v-rob opened 6 years ago

v-rob commented 6 years ago

If you set boost_cart.speed_max to a low value such as 1 and push the cart up/down a hill, the cart will move slightly faster than the max speed in some places, but at other points on the slope, it will move the normal speed.

I used a slope that went up three nodes with powered rail. If the powered rail's acceleration is set to a very large value, like 500, then the jerking movement is much more apparent.

SmallJoker commented 6 years ago

Does it happen with the current HEAD? Please keep in mind that for performance reasons, boost_cart and the MTG carts only update the velocity, acceleration and position each node (or server step, depending on what's larger).

v-rob commented 3 years ago

Just a note: this still happens. I think I've identified the problem, however. This code:

https://github.com/SmallJoker/boost_cart/blob/b05a49afb5721d09ceac3c5f4acfb793fe946914/cart_entity.lua#L329-L333

only limits the acceleration if the cart is currently going faster than it should once per node. However, acceleration is not limited otherwise and is set with set_acceleration. So, when going at a max_speed of 1, the acceleration is only limited once every node, so the cart can speed up in between nodes. So, the solution would be something like making the speed check happen every on_step instead of once per node.