From: oilboi <47129783+oilboi@users.noreply.github.com> Date: Mon, 6 Jul 2020 01:16:15 +0000 (-0400) Subject: Tune coupling collision detection more X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=42320666131d3c33db2ef17ea70dd46eb4fb9a4f;p=Crafter.git Tune coupling collision detection more --- diff --git a/mods/train/init.lua b/mods/train/init.lua index fe87750..aaa2605 100644 --- a/mods/train/init.lua +++ b/mods/train/init.lua @@ -239,7 +239,13 @@ local function coupling_logic(self) if vector.equals(coupler_velocity,vector.new(0,0,0)) then new_vel = vector.multiply(velocity_real,-1) else - new_vel = vector.multiply(velocity_real,-0.05) + local c_vel = vector.distance(vector.new(0,0,0),coupler_velocity) + local a_vel = vector.distance(vector.new(0,0,0),velocity_real) + local d_vel = a_vel-c_vel + if d_vel < 0 then + d_vel = 0 + end + new_vel = vector.multiply(self.dir,d_vel) end end self.object:add_velocity(new_vel) @@ -256,7 +262,13 @@ local function coupling_logic(self) if vector.equals(coupler_velocity,vector.new(0,0,0)) then new_vel = vector.multiply(velocity_real,-1) else - new_vel = vector.multiply(velocity_real,-0.05) + local c_vel = vector.distance(vector.new(0,0,0),coupler_velocity) + local a_vel = vector.distance(vector.new(0,0,0),velocity_real) + local d_vel = a_vel-c_vel + if d_vel < 0 then + d_vel = 0 + end + new_vel = vector.multiply(self.dir,d_vel) end end self.object:add_velocity(new_vel)