mirror of
https://github.com/SmallJoker/boost_cart.git
synced 2024-12-25 02:10:19 +01:00
Fix jerky movement on punch
This commit is contained in:
parent
cf9b82de37
commit
de5fb1825a
@ -143,7 +143,6 @@ end
|
|||||||
|
|
||||||
function cart_entity:on_step(dtime)
|
function cart_entity:on_step(dtime)
|
||||||
local vel = self.object:getvelocity()
|
local vel = self.object:getvelocity()
|
||||||
local update = {}
|
|
||||||
if self.punched then
|
if self.punched then
|
||||||
vel = vector.add(vel, self.velocity)
|
vel = vector.add(vel, self.velocity)
|
||||||
self.object:setvelocity(vel)
|
self.object:setvelocity(vel)
|
||||||
@ -153,6 +152,7 @@ function cart_entity:on_step(dtime)
|
|||||||
end
|
end
|
||||||
|
|
||||||
local pos = self.object:getpos()
|
local pos = self.object:getpos()
|
||||||
|
local update = {}
|
||||||
|
|
||||||
if self.old_pos and not self.punched then
|
if self.old_pos and not self.punched then
|
||||||
local flo_pos = vector.round(pos)
|
local flo_pos = vector.round(pos)
|
||||||
@ -175,9 +175,8 @@ function cart_entity:on_step(dtime)
|
|||||||
|
|
||||||
if self.old_pos then
|
if self.old_pos then
|
||||||
-- Detection for "skipping" nodes
|
-- Detection for "skipping" nodes
|
||||||
local expected_pos = vector.add(self.old_pos, self.old_dir)
|
|
||||||
local found_path = boost_cart:pathfinder(
|
local found_path = boost_cart:pathfinder(
|
||||||
pos, expected_pos, self.old_dir, ctrl, self.old_switch, self.railtype
|
pos, self.old_pos, self.old_dir, ctrl, self.old_switch, self.railtype
|
||||||
)
|
)
|
||||||
|
|
||||||
if not found_path then
|
if not found_path then
|
||||||
@ -344,7 +343,6 @@ function cart_entity:on_step(dtime)
|
|||||||
if update.pos then
|
if update.pos then
|
||||||
self.object:setpos(pos)
|
self.object:setpos(pos)
|
||||||
end
|
end
|
||||||
update = nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
minetest.register_entity(":carts:cart", cart_entity)
|
minetest.register_entity(":carts:cart", cart_entity)
|
||||||
|
@ -158,9 +158,9 @@ function boost_cart:get_rail_direction(pos_, dir, ctrl, old_switch, railtype)
|
|||||||
return {x=0, y=0, z=0}
|
return {x=0, y=0, z=0}
|
||||||
end
|
end
|
||||||
|
|
||||||
function boost_cart:pathfinder(pos_, expected_pos, old_dir, ctrl, pf_switch, railtype)
|
function boost_cart:pathfinder(pos_, old_pos, old_dir, ctrl, pf_switch, railtype)
|
||||||
local pos = vector.round(pos_)
|
local pos = vector.round(pos_)
|
||||||
local pf_pos = vector.round(expected_pos)
|
local pf_pos = vector.round(old_pos)
|
||||||
local pf_dir = vector.new(old_dir)
|
local pf_dir = vector.new(old_dir)
|
||||||
|
|
||||||
for i = 1, 3 do
|
for i = 1, 3 do
|
||||||
|
Loading…
Reference in New Issue
Block a user