diff --git a/include/Game/Systems/PlayerMovementSystem.h b/include/Game/Systems/PlayerMovementSystem.h
index bf7b4718..981fc13a 100644
--- a/include/Game/Systems/PlayerMovementSystem.h
+++ b/include/Game/Systems/PlayerMovementSystem.h
@@ -30,6 +30,8 @@ private:
bool m_LeftFoot = false;
// To get a difference when calculating the walking state.
glm::vec3 m_LastPosition = glm::vec3();
+ // Used to track afterimages for sprint effect.
+ float m_SprintEffectTimer;
// The logic for making the sound play when player is moving
void playerStep(double dt);
// Spawn a hexagon at origin of an Entity
diff --git a/resources/Schema/Components/SprintAbility.xml b/resources/Schema/Components/SprintAbility.xml
index 5cc59a3a..d9727ed9 100644
--- a/resources/Schema/Components/SprintAbility.xml
+++ b/resources/Schema/Components/SprintAbility.xml
@@ -1,4 +1,5 @@
- 2.0
+ 1.3
+ false
\ No newline at end of file
diff --git a/resources/Schema/Components/SprintAbility.xsd b/resources/Schema/Components/SprintAbility.xsd
index 9eabb450..7fe0d65a 100644
--- a/resources/Schema/Components/SprintAbility.xsd
+++ b/resources/Schema/Components/SprintAbility.xsd
@@ -12,6 +12,9 @@
This is the strength of the sprint effect
+
+ True if currently sprinting.
+
diff --git a/resources/Schema/Entities/SprintEffect.xml b/resources/Schema/Entities/SprintEffect.xml
new file mode 100644
index 00000000..6e892f8f
--- /dev/null
+++ b/resources/Schema/Entities/SprintEffect.xml
@@ -0,0 +1,25 @@
+
+
+
+
+
+
+
+
+
+
+ 0.15
+
+
+
+ 0.15
+
+
+
+
+
+
+
+
+
+
diff --git a/src/Game/Systems/PlayerMovementSystem.cpp b/src/Game/Systems/PlayerMovementSystem.cpp
index b116bcd9..025a8b70 100644
--- a/src/Game/Systems/PlayerMovementSystem.cpp
+++ b/src/Game/Systems/PlayerMovementSystem.cpp
@@ -2,6 +2,7 @@
PlayerMovementSystem::PlayerMovementSystem(SystemParams params)
: System(params)
+ , m_SprintEffectTimer(0.f)
{
EVENT_SUBSCRIBE_MEMBER(m_EPlayerSpawned, &PlayerMovementSystem::OnPlayerSpawned);
EVENT_SUBSCRIBE_MEMBER(m_EDoubleJump, &PlayerMovementSystem::OnDoubleJump);
@@ -19,8 +20,48 @@ void PlayerMovementSystem::Update(double dt)
{
updateMovementControllers(dt);
// Only do physics calculations on client and only for themselves.
- if (IsClient && LocalPlayer.Valid()) {
- updateVelocity(LocalPlayer, dt);
+ if (IsClient) {
+ if (LocalPlayer.Valid()){
+ updateVelocity(LocalPlayer, dt);
+ }
+ m_SprintEffectTimer += dt;
+ if (m_SprintEffectTimer < 0.016f) {
+ return;
+ }
+ m_SprintEffectTimer = 0.f;
+ const ComponentPool* pool = m_World->GetComponents("SprintAbility");
+ if (pool == nullptr) {
+ return;
+ }
+ for (auto cSprint : *pool) {
+ if (cSprint.EntityID != LocalPlayer.ID && (bool)cSprint["Active"]) {
+ // Spawn one afterimage for each player that sprints.
+ EntityWrapper player(m_World, cSprint.EntityID);
+ auto entityFile = ResourceManager::Load("Schema/Entities/SprintEffect.xml");
+ EntityWrapper sprintEffect = entityFile->MergeInto(m_World);
+ auto playerModel = player.FirstChildByName("PlayerModel");
+ if (!playerModel.Valid()) {
+ continue;
+ }
+ if (!playerModel.HasComponent("Model")) {
+ continue;
+ }
+ if (!playerModel.HasComponent("Animation")) {
+ continue;
+ }
+ auto playerEntityModel = playerModel["Model"];
+ auto playerEntityAnimation = playerModel["Animation"];
+ playerEntityModel.Copy(sprintEffect["Model"]);
+ playerEntityAnimation.Copy(sprintEffect["Animation"]);
+ sprintEffect["ExplosionEffect"]["EndColor"] = (glm::vec4)playerEntityModel["Color"];
+ ((glm::vec4&)sprintEffect["ExplosionEffect"]["EndColor"]).w = 0.f;
+ sprintEffect["Animation"]["Speed1"] = 0.0;
+ sprintEffect["Animation"]["Speed2"] = 0.0;
+ sprintEffect["Animation"]["Speed3"] = 0.0;
+ sprintEffect["Transform"]["Position"] = (glm::vec3)player["Transform"]["Position"];
+ sprintEffect["Transform"]["Orientation"] = (glm::vec3)player["Transform"]["Orientation"];
+ }
+ }
}
}
@@ -64,6 +105,7 @@ void PlayerMovementSystem::updateMovementControllers(double dt)
}
bool sniperSprinting = false;
if (player.HasComponent("SprintAbility")) {
+ (bool)player["SprintAbility"]["Active"] = controller->SpecialAbilityKeyDown();
if (controller->SpecialAbilityKeyDown()) {
playerMovementSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"];
playerCrouchSpeed *= (double)player["SprintAbility"]["StrengthOfEffect"];