mirror of
https://codeberg.org/tenplus1/mobs_redo.git
synced 2024-12-23 09:10:22 +01:00
tweak mobs.drive() speed (thanks auouymous)
This commit is contained in:
parent
fb42be6b28
commit
0e72f0ca81
16
mount.lua
16
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
|
||||
|
Loading…
Reference in New Issue
Block a user