mirror of
https://github.com/minetest/minetest.git
synced 2024-11-27 01:53:45 +01:00
Play object footstep sound at feet
This commit is contained in:
parent
7283d2495f
commit
fc116ec950
@ -1173,14 +1173,16 @@ void GenericCAO::step(float dtime, ClientEnvironment *env)
|
||||
m_step_distance_counter = 0.0f;
|
||||
if (!m_is_local_player && m_prop.makes_footstep_sound) {
|
||||
const NodeDefManager *ndef = m_client->ndef();
|
||||
v3s16 p = floatToInt(getPosition() +
|
||||
v3f(0.0f, (m_prop.collisionbox.MinEdge.Y - 0.5f) * BS, 0.0f), BS);
|
||||
MapNode n = m_env->getMap().getNode(p);
|
||||
v3f foot_pos = getPosition() * (1.0f/BS)
|
||||
+ v3f(0.0f, m_prop.collisionbox.MinEdge.Y, 0.0f);
|
||||
v3s16 node_below_pos = floatToInt(foot_pos + v3f(0.0f, -0.5f, 0.0f),
|
||||
1.0f);
|
||||
MapNode n = m_env->getMap().getNode(node_below_pos);
|
||||
SimpleSoundSpec spec = ndef->get(n).sound_footstep;
|
||||
// Reduce footstep gain, as non-local-player footsteps are
|
||||
// somehow louder.
|
||||
spec.gain *= 0.6f;
|
||||
m_client->sound()->playSoundAt(spec, getPosition());
|
||||
m_client->sound()->playSoundAt(spec, foot_pos * BS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user