diff --git a/automobiles_lib/entities.lua b/automobiles_lib/entities.lua index ddc794d..319ee20 100644 --- a/automobiles_lib/entities.lua +++ b/automobiles_lib/entities.lua @@ -558,7 +558,7 @@ function automobiles_lib.on_step(self, dtime) local min_later_speed = self._min_later_speed or 3 if (later_speed > min_later_speed or later_speed < -min_later_speed) then - automobiles_lib.add_smoke(curr_pos) + automobiles_lib.add_smoke(curr_pos, yaw, self._rear_wheel_xpos) if automobiles_lib.extra_drift == false then --disables the sound when playing drift game.. it's annoying if self._last_time_drift_snd >= 2.0 then self._last_time_drift_snd = 0 diff --git a/automobiles_lib/init.lua b/automobiles_lib/init.lua index c3cf72c..d9ddf96 100755 --- a/automobiles_lib/init.lua +++ b/automobiles_lib/init.lua @@ -88,7 +88,7 @@ function automobiles_lib.properties_copy(origin_table) return tablecopy end -function automobiles_lib.add_smoke(pos) +local function smoke_particle(pos) minetest.add_particle({ pos = pos, velocity = {x = 0, y = 0, z = 0}, @@ -102,6 +102,26 @@ function automobiles_lib.add_smoke(pos) }) end +function automobiles_lib.add_smoke(pos, yaw, rear_wheel_xpos) + local direction = yaw + + --right + local move = rear_wheel_xpos/10 + local smk_pos = vector.new(pos) + smk_pos.x = smk_pos.x + move * math.cos(direction) + smk_pos.z = smk_pos.z + move * math.sin(direction) + + smoke_particle(smk_pos) + + --left + direction = direction - math.rad(180) + smk_pos = vector.new(pos) + smk_pos.x = smk_pos.x + move * math.cos(direction) + smk_pos.z = smk_pos.z + move * math.sin(direction) + + smoke_particle(smk_pos) +end + --returns 0 for old, 1 for new function automobiles_lib.detect_player_api(player) local player_proterties = player:get_properties()