From 0e72f0ca811879e89a3c32049689350ece9191ec Mon Sep 17 00:00:00 2001 From: tenplus1 Date: Mon, 18 Apr 2022 08:31:25 +0100 Subject: [PATCH] tweak mobs.drive() speed (thanks auouymous) --- mount.lua | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/mount.lua b/mount.lua index 331caa5..be19ab2 100644 --- a/mount.lua +++ b/mount.lua @@ -254,7 +254,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) -- move forwards if ctrl.up then - entity.v = entity.v + entity.accel / 10 + entity.v = entity.v + entity.accel * dtime -- move backwards elseif ctrl.down then @@ -263,7 +263,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) return end - entity.v = entity.v - entity.accel / 10 + entity.v = entity.v - entity.accel * dtime end -- mob rotation @@ -355,14 +355,10 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime) end -- enforce speed limit forward and reverse - local max_spd = entity.max_speed_reverse - - if get_sign(entity.v) >= 0 then - max_spd = entity.max_speed_forward - end - - if abs(entity.v) > max_spd then - entity.v = entity.v - get_sign(entity.v) + if entity.v > entity.max_speed_forward then + entity.v = entity.max_speed_forward + elseif entity.v < -entity.max_speed_reverse then + entity.v = -entity.max_speed_reverse end -- Set position, velocity and acceleration