0
0
Fork 0

turning slows the player down in fly mode

This commit is contained in:
Sumyjkl 2022-08-02 08:20:08 +10:00
parent 2b5e3b5123
commit 8378ca92e2
1 changed files with 2 additions and 0 deletions

View File

@ -300,12 +300,14 @@ minetest.register_globalstep(function(dtime)
local max_speed = 120
local direction = player:get_look_dir()
local player_vel = player:get_velocity()
local turn_amount = anglediff(minetest.dir_to_yaw(direction), minetest.dir_to_yaw(player_vel))
local direction_mult = clamp(-direction.y*2, -0.5, 0.5)
local speed_mult = elytra.speed + direction_mult * speedup_mult * dtime
speed_mult = speed_mult - slowdown_mult * dtime -- slow down
speed_mult = math.max(speed_mult, -1)
speed_mult = math.min(speed_mult, max_speed)
speed_mult = speed_mult - (speed_mult * turn_amount / (math.pi*3))
elytra.speed = speed_mult -- set the speed so you can keep track of it and add to it
new_vel = direction -- use the facing direction as a base