Basic jumping!

This commit is contained in:
2016-01-23 12:15:24 +01:00
parent 3aeeb3cad5
commit 32f73201c5
3 changed files with 102 additions and 85 deletions
@@ -28,6 +28,8 @@ void PlayerMovementSystem::Update(double dt)
if (cameraEntity.Valid()) {
glm::vec3& cameraOrientation = cameraEntity["Transform"]["Orientation"];
cameraOrientation.x += controller->Rotation().x;
// Limit camera pitch so we don't break our necks
cameraOrientation.x = glm::clamp(cameraOrientation.x, -glm::half_pi<float>(), glm::half_pi<float>());
}
ComponentWrapper& cTransform = player["Transform"];
@@ -36,6 +38,13 @@ void PlayerMovementSystem::Update(double dt)
glm::vec3& pos = cTransform["Position"];
pos += controller->Movement() * glm::inverse(glm::quat(ori)) * (float)player["Player"]["MovementSpeed"] * (float)dt;
if (player.HasComponent("Physics")) {
if (controller->Jumping()) {
glm::vec3& velocity = player["Physics"]["Velocity"];
velocity.y += 10.f;
}
}
controller->Reset();
}