aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/game.cpp2
-rw-r--r--src/localplayer.cpp12
-rw-r--r--src/localplayer.h1
3 files changed, 14 insertions, 1 deletions
diff --git a/src/game.cpp b/src/game.cpp
index 840403c42..1735737de 100644
--- a/src/game.cpp
+++ b/src/game.cpp
@@ -3530,7 +3530,7 @@ void Game::updateSound(f32 dtime)
LocalPlayer *player = client->getEnv().getLocalPlayer();
ClientMap &map = client->getEnv().getClientMap();
- MapNode n = map.getNodeNoEx(player->getStandingNodePos());
+ MapNode n = map.getNodeNoEx(player->getFootstepNodePos());
soundmaker->m_player_step_sound = nodedef_manager->get(n).sound_footstep;
}
diff --git a/src/localplayer.cpp b/src/localplayer.cpp
index 857d95d8b..33932df0b 100644
--- a/src/localplayer.cpp
+++ b/src/localplayer.cpp
@@ -655,6 +655,18 @@ v3s16 LocalPlayer::getStandingNodePos()
return floatToInt(getPosition() - v3f(0, BS, 0), BS);
}
+v3s16 LocalPlayer::getFootstepNodePos()
+{
+ if (touching_ground)
+ // BS * 0.05 below the player's feet ensures a 1/16th height
+ // nodebox is detected instead of the node below it.
+ return floatToInt(getPosition() - v3f(0, BS * 0.05f, 0), BS);
+ // A larger distance below is necessary for a footstep sound
+ // when landing after a jump or fall. BS * 0.5 ensures water
+ // sounds when swimming in 1 node deep water.
+ return floatToInt(getPosition() - v3f(0, BS * 0.5f, 0), BS);
+}
+
v3s16 LocalPlayer::getLightPosition() const
{
return floatToInt(m_position + v3f(0,BS+BS/2,0), BS);
diff --git a/src/localplayer.h b/src/localplayer.h
index 685a78cb3..b48dacdb7 100644
--- a/src/localplayer.h
+++ b/src/localplayer.h
@@ -68,6 +68,7 @@ public:
void applyControl(float dtime);
v3s16 getStandingNodePos();
+ v3s16 getFootstepNodePos();
// Used to check if anything changed and prevent sending packets if not
v3f last_position;