improved drift effect and changed beetle engine sound

This commit is contained in:
Alexsandro Percy 2024-11-17 15:16:07 -03:00
parent db9207d131
commit a3c2179f29
4 changed files with 40 additions and 22 deletions

View File

@ -373,6 +373,7 @@ auto_beetle.car_properties1 = {
_is_flying = 0,
_trunk_slots = 12,
_engine_sound = "beetle_engine",
_base_pitch = 0.7,
_max_fuel = 10,
_vehicle_name = "Beetle",

BIN
automobiles_beetle/sounds/beetle_engine.ogg Executable file → Normal file

Binary file not shown.

View File

@ -564,25 +564,6 @@ function automobiles_lib.on_step(self, dtime)
local noded = automobiles_lib.nodeatpos(automobiles_lib.pos_shift(curr_pos,{y=self.initial_properties.collisionbox[2]-0.5}))
if (noded and noded.drawtype ~= 'airlike') then
if noded.drawtype ~= 'liquid' then
local min_later_speed = self._min_later_speed or 3
local speed_for_smoke = min_later_speed / 2
if (later_speed > speed_for_smoke or later_speed < -speed_for_smoke) and not self._is_motorcycle then
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 and (later_speed > min_later_speed or later_speed < -min_later_speed) then
self._last_time_drift_snd = 0
minetest.sound_play("automobiles_drifting", {
pos = curr_pos,
max_hear_distance = 20,
gain = 3.0,
fade = 0.0,
pitch = 1.0,
ephemeral = true,
})
end
end
end
local wheel_compensation = longit_speed * (self._wheel_compensation or 1)
if self.lf_wheel then self.lf_wheel:set_animation_frame_speed( wheel_compensation * (12 - angle_factor)) end
if self.rf_wheel then self.rf_wheel:set_animation_frame_speed(-wheel_compensation * (12 + angle_factor)) end
@ -744,10 +725,45 @@ function automobiles_lib.on_step(self, dtime)
else
if turn_effect_speed > 10 then turn_effect_speed = 10 end
if math.abs(longit_speed) > 0 then
local tilt_effect = (-self._steering_angle/100)*(turn_effect_speed/20)
--local tilt_effect = (-self._steering_angle/100)*(turn_effect_speed/30)
local max_tilt = 10
local tilt_effect = (-later_speed/12)*(turn_effect_speed/30)
local tire_burn = false
if tilt_effect > max_tilt then
tilt_effect = max_tilt
end
if tilt_effect < -max_tilt then
tilt_effect = -max_tilt
end
newroll = tilt_effect * -1
self.front_suspension:set_rotation({x=0,y=0,z=tilt_effect})
self.rear_suspension:set_rotation({x=0,y=0,z=tilt_effect})
if (noded and noded.drawtype ~= 'airlike') then
if noded.drawtype ~= 'liquid' then
local min_later_speed = self._min_later_speed or 3
local speed_for_smoke = min_later_speed / 2
if (later_speed > speed_for_smoke or later_speed < -speed_for_smoke) and not self._is_motorcycle then
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 and (later_speed > min_later_speed or later_speed < -min_later_speed) then
self._last_time_drift_snd = 0
minetest.sound_play("automobiles_drifting", {
pos = curr_pos,
max_hear_distance = 20,
gain = 3.0,
fade = 0.0,
pitch = 1.0,
ephemeral = true,
})
end
end
end
end
end
else
self.front_suspension:set_rotation({x=0,y=0,z=0})
self.rear_suspension:set_rotation({x=0,y=0,z=0})

View File

@ -568,9 +568,10 @@ function automobiles_lib.engineSoundPlay(self)
local base_pitch = 1
if self._base_pitch then base_pitch = self._base_pitch end
local snd_pitch = base_pitch + ((self._longit_speed/10)/2)
local divisor = 6 --3 states, so 6 to make it more smooth
local snd_pitch = base_pitch + ((base_pitch/divisor)*self._transmission_state) + ((self._longit_speed/10)/2)
if self._transmission_state == 1 then
snd_pitch = 1 + (self._longit_speed/10)
snd_pitch = base_pitch + (self._longit_speed/10)
end
self.sound_handle = minetest.sound_play({name = self._engine_sound},