Experimental player terminal velocity.

Note that for extremely long falls, something
still needs to be done for items falling in
parallel with players, since as it is right now,
then fall at different speeds.

Even with player velocity being limited,
objects tend to fall at much slower speeds
initially than players, and collide with
unloaded areas and "settle" into node space,
requriing an ABM to release them again.
Instead, when a falling item collides with an
unloaded area, we need a way to preserve
its speed until the area is loaded, and then
continue falling.
This commit is contained in:
Aaron Suen 2019-12-31 23:24:29 -05:00
parent 5a7567a73c
commit fb256cf8bd
2 changed files with 27 additions and 0 deletions

View File

@ -0,0 +1,26 @@
-- LUALOCALS < ---------------------------------------------------------
local minetest, pairs
= minetest, pairs
-- LUALOCALS > ---------------------------------------------------------
-- Terminal velocity = 50m/s, reasonable based on Wikipedia
local friction = 0.0004
local cached = {}
minetest.register_globalstep(function()
for _, player in pairs(minetest.get_connected_players()) do
local pname = player:get_player_name()
local v = player:get_player_velocity()
v = v.y < 0 and -v.y or 0
local g = 1 - friction * v * v
local og = cached[pname]
if g ~= og then
player:set_physics_override({gravity = g})
cached[pname] = g
end
end
end)
minetest.register_on_leaveplayer(function(player)
cached[player:get_player_name()] = nil
end)

View File

@ -7,3 +7,4 @@ nodecore.amcoremod()
include("setup")
include("hotpotato")
include("freefall")