improved drift smoke

This commit is contained in:
Alexsandro Percy 2024-06-05 21:15:28 -03:00
parent d86941174d
commit c383625242
2 changed files with 22 additions and 2 deletions

View File

@ -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

View File

@ -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()