1
0
mirror of https://codeberg.org/tenplus1/mobs_redo.git synced 2024-12-24 01:30:22 +01:00

tweak mobs.drive() speed (thanks auouymous)

This commit is contained in:
tenplus1 2022-04-18 08:31:25 +01:00
parent fb42be6b28
commit 0e72f0ca81

View File

@ -254,7 +254,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
-- move forwards -- move forwards
if ctrl.up then if ctrl.up then
entity.v = entity.v + entity.accel / 10 entity.v = entity.v + entity.accel * dtime
-- move backwards -- move backwards
elseif ctrl.down then elseif ctrl.down then
@ -263,7 +263,7 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
return return
end end
entity.v = entity.v - entity.accel / 10 entity.v = entity.v - entity.accel * dtime
end end
-- mob rotation -- mob rotation
@ -355,14 +355,10 @@ function mobs.drive(entity, moving_anim, stand_anim, can_fly, dtime)
end end
-- enforce speed limit forward and reverse -- enforce speed limit forward and reverse
local max_spd = entity.max_speed_reverse if entity.v > entity.max_speed_forward then
entity.v = entity.max_speed_forward
if get_sign(entity.v) >= 0 then elseif entity.v < -entity.max_speed_reverse then
max_spd = entity.max_speed_forward entity.v = -entity.max_speed_reverse
end
if abs(entity.v) > max_spd then
entity.v = entity.v - get_sign(entity.v)
end end
-- Set position, velocity and acceleration -- Set position, velocity and acceleration