added footsteps sound

This commit is contained in:
Alexsandro Percy 2022-07-02 15:39:05 -03:00
parent 9aefdfd6ca
commit a1a7f96969
2 changed files with 23 additions and 11 deletions

View File

@ -37,15 +37,16 @@ initial_properties = {
-- seat pivot
--
minetest.register_entity('steampunk_blimp:stand_base',{
initial_properties = {
physical = true,
collide_with_objects=true,
collisionbox = {-2, -2, -2, 2, 0, 2},
pointable=false,
visual = "mesh",
mesh = "steampunk_blimp_stand_base.b3d",
textures = {"steampunk_blimp_alpha.png",},
initial_properties = {
physical = true,
collide_with_objects=true,
collisionbox = {-2, -2, -2, 2, 0, 2},
pointable=false,
visual = "mesh",
mesh = "steampunk_blimp_stand_base.b3d",
textures = {"steampunk_blimp_alpha.png",},
},
dist_moved = 0,
on_activate = function(self,std)
self.sdata = minetest.deserialize(std) or {}
@ -56,7 +57,6 @@ initial_properties = {
self.sdata.remove=true
return minetest.serialize(self.sdata)
end,
})
minetest.register_entity("steampunk_blimp:blimp", {

View File

@ -540,7 +540,8 @@ function steampunk_blimp.play_rope_sound(self)
ephemeral = true,})
end
local function get_result_pos(self, player)
--note: index variable just for the walk
local function get_result_pos(self, player, index)
local pos = nil
if player then
local direction = player:get_look_horizontal()
@ -568,6 +569,17 @@ local function get_result_pos(self, player)
pos.x = move * math.cos(-direction)
pos.z = move * math.sin(-direction)
--lets fake walk sound
if self._passengers_base_pos[index].dist_moved == nil then self._passengers_base_pos[index].dist_moved = 0 end
self._passengers_base_pos[index].dist_moved = self._passengers_base_pos[index].dist_moved + move;
if math.abs(self._passengers_base_pos[index].dist_moved) > 5 then
self._passengers_base_pos[index].dist_moved = 0
minetest.sound_play({name = "default_wood_footstep"},
{object = player, gain = 0.05,
max_hear_distance = 5,
ephemeral = true,})
end
--[[
sin(theta) = opposite/hypotenuse
cos(theta) = adjacent/hypotenuse
@ -634,7 +646,7 @@ function steampunk_blimp.move_persons(self)
--minetest.chat_send_all("pass: "..dump(self._passengers[i]))
--the rest of the passengers
if player then
local result_pos = get_result_pos(self, player)
local result_pos = get_result_pos(self, player, i)
local y_rot = 0
if result_pos then
y_rot = result_pos.y -- the only field that returns a rotation