sound improved, added park leg

This commit is contained in:
Alexsandro Percy 2022-09-11 11:19:44 -03:00
parent 9c9e8e9f72
commit 891e6e9c63
5 changed files with 14 additions and 6 deletions

View File

@ -462,6 +462,7 @@ minetest.register_entity("automobiles_motorcycle:motorcycle", {
if stop == true then
self.object:set_acceleration({x=0,y=0,z=0})
self.object:set_velocity({x=0,y=0,z=0})
if self._longit_speed > 0 then motorcycle.engineSoundPlay(self) end
end
end
@ -476,7 +477,14 @@ minetest.register_entity("automobiles_motorcycle:motorcycle", {
if turn_effect_speed > 10 then turn_effect_speed = 10 end
local newroll = (-self._steering_angle/100)*(turn_effect_speed/10)
if newyaw~=yaw or newpitch~=pitch then self.object:set_rotation({x=newpitch,y=newyaw,z=newroll}) end
if is_attached == false then
newroll = math.rad(-12)
self.object:set_bone_position("descanso", {x=0, y=-2.55, z=5.9}, {x=-90, y=0, z=0})
else
self.object:set_bone_position("descanso", {x=0, y=-2.55, z=5.9}, {x=0, y=0, z=0})
end
self.object:set_rotation({x=newpitch,y=newyaw,z=newroll})
--saves last velocity for collision detection (abrupt stop)
self.lastvelocity = self.object:get_velocity()
@ -579,7 +587,7 @@ minetest.register_entity("automobiles_motorcycle:motorcycle", {
motorcycle.attach_driver_stand(self, clicker)
-- sound
self.sound_handle = minetest.sound_play({name = "motorcycle_engine"},
{object = self.object, gain = 4, pitch = 1, max_hear_distance = 10, loop = true,})
{object = self.object, gain = 1, pitch = 0.5, max_hear_distance = 30, loop = true,})
end
else
--minetest.chat_send_all("clicou")

View File

@ -46,7 +46,7 @@ end
function motorcycle.engine_set_sound_and_animation(self, _longit_speed)
--minetest.chat_send_all('test1 ' .. dump(self._engine_running) )
if self.sound_handle then
if (math.abs(self._longit_speed) > math.abs(_longit_speed) + 0.08) or (math.abs(self._longit_speed) + 0.08 < math.abs(_longit_speed)) then
if (math.abs(self._longit_speed) > math.abs(_longit_speed) + 0.06) or (math.abs(self._longit_speed) + 0.06 < math.abs(_longit_speed)) then
--minetest.chat_send_all('test2')
motorcycle.engineSoundPlay(self)
end
@ -58,9 +58,9 @@ function motorcycle.engineSoundPlay(self)
if self.sound_handle then minetest.sound_stop(self.sound_handle) end
if self.object then
self.sound_handle = minetest.sound_play({name = "motorcycle_engine"},
{object = self.object, gain = 8,
pitch = 1 + ((self._longit_speed/10)/2),
max_hear_distance = 10,
{object = self.object, gain = 1,
pitch = 0.5 + ((self._longit_speed/10)/2),
max_hear_distance = 30,
loop = true,})
end
end