add sound to motorbike

master
Elkien3 2020-09-08 00:41:39 -05:00
parent e233b3dc7e
commit 28d3eec210
5 changed files with 46 additions and 0 deletions

View File

@ -15,3 +15,6 @@ All other colours are edits of motorbike_blue.png by Melkor
motorbike_wheel_inv.png
motorbike_(colour)_imv.png (Render of Melkors bike)
motorbike_biker.b3d (Edited version of minetest player model from 3d_armor)
Alexander (CC BY-NC 4.0) <http://www.orangefreesounds.com/author/alexander/>
Harley Davidson Motorcycle Slow Pass By > motoengine.ogg

View File

@ -391,6 +391,49 @@ function biker.drive(entity, dtime)
entity.object:setvelocity(new_velo)
entity.object:setacceleration(new_acce)
entity.lastv = entity.object:getvelocity()
--sound
if entity.v > 0 and entity.driver ~= nil then
entity.timer1 = entity.timer1 + dtime
if entity.timer1 > .1 then
local rpm = 1
if entity.v > 7 then
rpm = entity.v/7+.4
elseif entity.v > 3 then
rpm = entity.v/3+.3
else
rpm = entity.v/3+.2
end
minetest.sound_play("motoengine", {
max_hear_distance = 48,
pitch = rpm+.1,
object = entity.object
})
entity.timer1 = 0
end
end
entity.timer2 = entity.timer2 + dtime
if entity.timer2 > 1.5-entity.v/max_spd*1.1 then
if math.abs(entity.v) > .2 then
if math.abs(velo.y) < .1 then
entity.wheelsound = minetest.sound_play("tyresound", {
max_hear_distance = 48,
object = entity.object,
pitch = 1.1 + (entity.v/max_spd)*.6,
gain = .5 + (entity.v/max_spd)*2
})
elseif entity.windsound then
minetest.sound_fade(entity.windsound, 30, 0)
end
entity.windsound = minetest.sound_play("wind", {
max_hear_distance = 10,
object = entity.object,
pitch = 1 + (entity.v/max_spd)*.6,
gain = 0 + (entity.v/max_spd)*4
})
end
entity.timer2 = 0
end
end
minetest.register_on_leaveplayer(function(player)

BIN
sounds/motoengine.ogg Normal file

Binary file not shown.

BIN
sounds/tyresound.ogg Normal file

Binary file not shown.

BIN
sounds/wind.ogg Normal file

Binary file not shown.