forked from minetest/minetest_game
Boats: Properly use 'dtime' for consistent responsiveness
Previously, boat responsiveness varied greatly depending on server lag and singleplayer / multiplayer. 'dtime' is the time from the last execution of the boat entity 'on step' function, so must multiply acceleration and yaw change. Retune acceleration, turn rate and drift deceleration. Make reversed turn only happen with significant backwards speed.
This commit is contained in:
parent
7e1b07fddd
commit
5c8bd34957
@ -141,26 +141,26 @@ function boat.on_step(self, dtime)
|
|||||||
"[boats] Cruise on")
|
"[boats] Cruise on")
|
||||||
end
|
end
|
||||||
elseif ctrl.down then
|
elseif ctrl.down then
|
||||||
self.v = self.v - 0.1
|
self.v = self.v - dtime * 1.8
|
||||||
if self.auto then
|
if self.auto then
|
||||||
self.auto = false
|
self.auto = false
|
||||||
minetest.chat_send_player(driver_name,
|
minetest.chat_send_player(driver_name,
|
||||||
"[boats] Cruise off")
|
"[boats] Cruise off")
|
||||||
end
|
end
|
||||||
elseif ctrl.up or self.auto then
|
elseif ctrl.up or self.auto then
|
||||||
self.v = self.v + 0.1
|
self.v = self.v + dtime * 1.8
|
||||||
end
|
end
|
||||||
if ctrl.left then
|
if ctrl.left then
|
||||||
if self.v < 0 then
|
if self.v < -0.001 then
|
||||||
self.object:set_yaw(self.object:get_yaw() - (1 + dtime) * 0.03)
|
self.object:set_yaw(self.object:get_yaw() - dtime * 0.9)
|
||||||
else
|
else
|
||||||
self.object:set_yaw(self.object:get_yaw() + (1 + dtime) * 0.03)
|
self.object:set_yaw(self.object:get_yaw() + dtime * 0.9)
|
||||||
end
|
end
|
||||||
elseif ctrl.right then
|
elseif ctrl.right then
|
||||||
if self.v < 0 then
|
if self.v < -0.001 then
|
||||||
self.object:set_yaw(self.object:get_yaw() + (1 + dtime) * 0.03)
|
self.object:set_yaw(self.object:get_yaw() + dtime * 0.9)
|
||||||
else
|
else
|
||||||
self.object:set_yaw(self.object:get_yaw() - (1 + dtime) * 0.03)
|
self.object:set_yaw(self.object:get_yaw() - dtime * 0.9)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -170,7 +170,7 @@ function boat.on_step(self, dtime)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
local s = get_sign(self.v)
|
local s = get_sign(self.v)
|
||||||
self.v = self.v - 0.02 * s
|
self.v = self.v - dtime * 0.6 * s
|
||||||
if s ~= get_sign(self.v) then
|
if s ~= get_sign(self.v) then
|
||||||
self.object:set_velocity({x = 0, y = 0, z = 0})
|
self.object:set_velocity({x = 0, y = 0, z = 0})
|
||||||
self.v = 0
|
self.v = 0
|
||||||
|
Loading…
Reference in New Issue
Block a user