add sound to motorbike
This commit is contained in:
parent
e233b3dc7e
commit
28d3eec210
3
LICENSE
3
LICENSE
@ -15,3 +15,6 @@ All other colours are edits of motorbike_blue.png by Melkor
|
|||||||
motorbike_wheel_inv.png
|
motorbike_wheel_inv.png
|
||||||
motorbike_(colour)_imv.png (Render of Melkors bike)
|
motorbike_(colour)_imv.png (Render of Melkors bike)
|
||||||
motorbike_biker.b3d (Edited version of minetest player model from 3d_armor)
|
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
|
@ -391,6 +391,49 @@ function biker.drive(entity, dtime)
|
|||||||
entity.object:setvelocity(new_velo)
|
entity.object:setvelocity(new_velo)
|
||||||
entity.object:setacceleration(new_acce)
|
entity.object:setacceleration(new_acce)
|
||||||
entity.lastv = entity.object:getvelocity()
|
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
|
end
|
||||||
|
|
||||||
minetest.register_on_leaveplayer(function(player)
|
minetest.register_on_leaveplayer(function(player)
|
||||||
|
BIN
sounds/motoengine.ogg
Normal file
BIN
sounds/motoengine.ogg
Normal file
Binary file not shown.
BIN
sounds/tyresound.ogg
Normal file
BIN
sounds/tyresound.ogg
Normal file
Binary file not shown.
BIN
sounds/wind.ogg
Normal file
BIN
sounds/wind.ogg
Normal file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user