Crude animations
This commit is contained in:
+1
-1
Submodule assets updated: 5f3ab8b35d...7577819337
@@ -198,7 +198,7 @@
|
||||
</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="-0.246963501" Y="0.0264999866" Z="3.01600003"/>
|
||||
<Position X="-1.68112314" Y="0.0264999866" Z="3.06287026"/>
|
||||
<Orientation X="0" Y="2.14675093" Z="0"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
|
||||
@@ -7,7 +7,6 @@
|
||||
<Size X="1" Y="1.60000002" Z="1"/>
|
||||
</c:AABB>
|
||||
<c:Collidable/>
|
||||
<c:Model/>
|
||||
<c:Physics/>
|
||||
<c:Player>
|
||||
<MovementSpeed>5</MovementSpeed>
|
||||
@@ -18,8 +17,7 @@
|
||||
</Team>
|
||||
</c:Team>
|
||||
<c:Transform>
|
||||
<Position X="-0.246963501" Y="0.0265000071" Z="3.01600003"/>
|
||||
<Orientation X="0" Y="2.14675093" Z="0"/>
|
||||
<Position X="-0.246963501" Y="0.0264999941" Z="3.01600003"/>
|
||||
</c:Transform>
|
||||
</Components>
|
||||
|
||||
@@ -51,6 +49,7 @@
|
||||
<Components>
|
||||
<c:Model>
|
||||
<Resource>Models/Camera.mesh</Resource>
|
||||
<Visible>false</Visible>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Position X="0" Y="0.0331346765" Z="-0.0792061687"/>
|
||||
@@ -77,13 +76,15 @@
|
||||
</Entity>
|
||||
<Entity name="PlayerModel">
|
||||
<Components>
|
||||
<c:Animation>
|
||||
<Name>Hold Pos</Name>
|
||||
<Speed>1</Speed>
|
||||
</c:Animation>
|
||||
<c:Model>
|
||||
<Resource>Models/AssaultHeadless.mesh</Resource>
|
||||
<Resource>Models/AssaultAnimated.mesh</Resource>
|
||||
<Color A="1" B="0" G="0" R="1"/>
|
||||
</c:Model>
|
||||
<c:Transform>
|
||||
<Orientation X="0" Y="3.14159274" Z="0"/>
|
||||
</c:Transform>
|
||||
<c:Transform/>
|
||||
</Components>
|
||||
<Children/>
|
||||
</Entity>
|
||||
|
||||
@@ -36,15 +36,18 @@ void PlayerMovementSystem::Update(double dt)
|
||||
glm::vec3& ori = cTransform["Orientation"];
|
||||
ori.y += controller->Rotation().y;
|
||||
|
||||
float playerMovementSpeed = player["Player"]["MovementSpeed"];
|
||||
float playerCrouchSpeed = player["Player"]["CrouchSpeed"];
|
||||
|
||||
if (player.HasComponent("Physics")) {
|
||||
ComponentWrapper cPhysics = player["Physics"];
|
||||
|
||||
glm::vec3 wishDirection = controller->Movement() * glm::inverse(glm::quat(ori));
|
||||
float wishSpeed;
|
||||
if (controller->Crouching()) {
|
||||
wishSpeed = player["Player"]["CrouchSpeed"];
|
||||
wishSpeed = playerCrouchSpeed;
|
||||
} else {
|
||||
wishSpeed = player["Player"]["MovementSpeed"];
|
||||
wishSpeed = playerMovementSpeed;
|
||||
}
|
||||
glm::vec3& velocity = cPhysics["Velocity"];
|
||||
ImGui::Text("velocity: (%f, %f, %f)", velocity.x, velocity.y, velocity.z);
|
||||
@@ -85,8 +88,33 @@ void PlayerMovementSystem::Update(double dt)
|
||||
// size = glm::vec3(1.f, 1.6f, 1.f);
|
||||
// }
|
||||
//}
|
||||
|
||||
// Animations
|
||||
EntityWrapper playerModel = player.FirstChildByName("PlayerModel");
|
||||
if (playerModel.Valid()) {
|
||||
ComponentWrapper cAnimation = playerModel["Animation"];
|
||||
|
||||
float movementLength = glm::length(groundVelocity);
|
||||
if (glm::length(controller->Movement()) > 0.f) {
|
||||
if (controller->Crouching()) {
|
||||
cAnimation["Name"] = "Crouch Walk";
|
||||
(double&)cAnimation["Speed"] = 1.f * -glm::sign(controller->Movement().z);
|
||||
} else {
|
||||
cAnimation["Name"] = "Run";
|
||||
(double&)cAnimation["Speed"] = 2.f * -glm::sign(controller->Movement().z);
|
||||
}
|
||||
} else {
|
||||
if (controller->Crouching()) {
|
||||
cAnimation["Name"] = "Crouch";
|
||||
(double&)cAnimation["Speed"] = 1.f;
|
||||
} else {
|
||||
cAnimation["Name"] = "Hold Pos";
|
||||
(double&)cAnimation["Speed"] = 1.f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
controller->Reset();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user