X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Fui%2Fui.cpp;fp=src%2Fui%2Fui.cpp;h=f5664dc0f4828b894f80e983b233441c1397ebb7;hb=0d580658b896dfec07466c31ae4847455724ee95;hp=263245cd79bfe61ccdeb57e710bc1f5951c67fd0;hpb=465bd7f96fbae44067bd342649e52c9187853b39;p=blank.git diff --git a/src/ui/ui.cpp b/src/ui/ui.cpp index 263245c..f5664dc 100644 --- a/src/ui/ui.cpp +++ b/src/ui/ui.cpp @@ -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 {