]> git.localhorst.tv Git - blank.git/blobdiff - src/ai/ai.cpp
split geometry lib
[blank.git] / src / ai / ai.cpp
index fc6abfc4b9e59fa0133ad1bb66c4776e4595b049..8386c59d174067b65fbcd241765902db023c09c2 100644 (file)
@@ -4,7 +4,8 @@
 #include "IdleState.hpp"
 #include "RoamState.hpp"
 
-#include "../model/geometry.hpp"
+#include "../geometry/distance.hpp"
+#include "../geometry/rotation.hpp"
 #include "../rand/GaloisLFSR.hpp"
 #include "../world/Entity.hpp"
 #include "../world/World.hpp"
@@ -100,9 +101,13 @@ void AIController::Update(Entity &e, float dt) {
        if (e.Moving()) {
                // orient head towards heading
                glm::vec3 heading(e.Heading());
-               float tgt_pitch = std::atan(heading.y / length(glm::vec2(heading.x, heading.z)));
-               float tgt_yaw = std::atan2(-heading.x, -heading.z);
+               // only half pitch, so we don't crane our neck
+               float tgt_pitch = std::atan(heading.y / length(glm::vec2(heading.x, heading.z))) * 0.5f;
+               // always look straight ahead
+               // maybe look at the pursuit target if there is one
+               float tgt_yaw = 0.0f;
                e.SetHead(tgt_pitch, tgt_yaw);
+               e.OrientBody(dt);
        }
 }