tweak mobs.drive() speed (thanks auouymous)

This commit is contained in:
tenplus1 2022-04-18 08:31:25 +01:00
parent fb42be6b28
commit 0e72f0ca81
1 changed files with 6 additions and 10 deletions

View File

@ -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