X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fai%2Fai.cpp;h=8386c59d174067b65fbcd241765902db023c09c2;hb=4fbf5a3c1b0e530706023f5fc4be2f68d30ea645;hp=fc6abfc4b9e59fa0133ad1bb66c4776e4595b049;hpb=170c0ff60b9679c954a9e74d5300c9929899b2bd;p=blank.git diff --git a/src/ai/ai.cpp b/src/ai/ai.cpp index fc6abfc..8386c59 100644 --- a/src/ai/ai.cpp +++ b/src/ai/ai.cpp @@ -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); } }