@@ -187,13 +187,12 @@ void PlayerMovementSystem::playerStep(double dt)
|
|||||||
}
|
}
|
||||||
// Position of the local player, used see how far a player has moved.
|
// Position of the local player, used see how far a player has moved.
|
||||||
glm::vec3 pos = (glm::vec3)m_World->GetComponent(m_LocalPlayer.ID, "Transform")["Position"];
|
glm::vec3 pos = (glm::vec3)m_World->GetComponent(m_LocalPlayer.ID, "Transform")["Position"];
|
||||||
// Velocity of the local player, used to see if a player is airborne.
|
// Used to see if a player is airborne.
|
||||||
glm::vec3 vel = (glm::vec3)m_World->GetComponent(m_LocalPlayer.ID, "Physics")["Velocity"];
|
bool grounded = (bool)m_World->GetComponent(m_LocalPlayer.ID, "Physics")["IsOnGround"];
|
||||||
m_DistanceMoved += glm::length(pos - m_LastPosition);
|
m_DistanceMoved += glm::length(pos - m_LastPosition);
|
||||||
// Set the last position for next iteration
|
// Set the last position for next iteration
|
||||||
m_LastPosition = pos;
|
m_LastPosition = pos;
|
||||||
bool isAirborne = vel.y != 0;
|
if (m_DistanceMoved > m_PlayerStepLength && grounded) {
|
||||||
if (m_DistanceMoved > m_PlayerStepLength && !isAirborne) {
|
|
||||||
// Player moved a step's distance
|
// Player moved a step's distance
|
||||||
// Create footstep sound
|
// Create footstep sound
|
||||||
Events::PlaySoundOnEntity e;
|
Events::PlaySoundOnEntity e;
|
||||||
|
|||||||
@@ -69,8 +69,8 @@ bool SoundSystem::OnInputCommand(const Events::InputCommand & e)
|
|||||||
|
|
||||||
void SoundSystem::playerJumps()
|
void SoundSystem::playerJumps()
|
||||||
{
|
{
|
||||||
glm::vec3 vel = (glm::vec3)m_World->GetComponent(m_LocalPlayer.ID, "Physics")["Velocity"];
|
bool grounded = (bool)m_World->GetComponent(m_LocalPlayer.ID, "Physics")["IsOnGround"];
|
||||||
if (vel.y == 0) {
|
if (grounded) {
|
||||||
Events::PlaySoundOnEntity e;
|
Events::PlaySoundOnEntity e;
|
||||||
e.EmitterID = m_LocalPlayer.ID;
|
e.EmitterID = m_LocalPlayer.ID;
|
||||||
e.FilePath = "Audio/jump/jump1.wav";
|
e.FilePath = "Audio/jump/jump1.wav";
|
||||||
|
|||||||
Reference in New Issue
Block a user