You can now DoubleJump!
This commit is contained in:
@@ -20,4 +20,6 @@ private:
|
|||||||
|
|
||||||
EventRelay<PlayerMovementSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
EventRelay<PlayerMovementSystem, Events::PlayerSpawned> m_EPlayerSpawned;
|
||||||
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
bool OnPlayerSpawned(Events::PlayerSpawned& e);
|
||||||
|
|
||||||
|
bool m_DoubleJumped = false;
|
||||||
};
|
};
|
||||||
@@ -76,7 +76,13 @@ void PlayerMovementSystem::Update(double dt)
|
|||||||
ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity));
|
ImGui::Text("velocity: (%f, %f, %f) |%f|", velocity.x, velocity.y, velocity.z, glm::length(velocity));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (controller->Jumping() && !controller->Crouching() && velocity.y == 0.f) {
|
if (controller->Jumping() && !controller->Crouching() && (velocity.y == 0.f || !m_DoubleJumped)) {
|
||||||
|
if (velocity.y == 0.f) {
|
||||||
|
m_DoubleJumped = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
m_DoubleJumped = true;
|
||||||
|
}
|
||||||
velocity.y += 4.f;
|
velocity.y += 4.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user