]> git.localhorst.tv Git - blank.git/blobdiff - src/ui/ui.cpp
new turn style
[blank.git] / src / ui / ui.cpp
index 263245cd79bfe61ccdeb57e710bc1f5951c67fd0..f5664dc0f4828b894f80e983b233441c1397ebb7 100644 (file)
@@ -60,7 +60,13 @@ void PlayerController::SetMovement(const glm::vec3 &m) noexcept {
 }
 
 glm::vec3 PlayerController::ControlForce(const Entity &e, const EntityState &s) const {
-       return TargetVelocity(rotateY(move_dir * e.MaxVelocity(), s.yaw), s, 5.0f);
+       if (!iszero(move_dir)) {
+               // scale input by max velocity, apply yaw, and transform to world space
+               return TargetVelocity(glm::vec3(glm::vec4(rotateY(move_dir * e.MaxVelocity(), s.yaw), 0.0f) * transpose(e.Transform())), s, 5.0f);
+       } else {
+               // target velocity of 0 is the same as halt
+               return Halt(s, 5.0f);
+       }
 }
 
 void PlayerController::TurnHead(float dp, float dy) noexcept {